0
点赞
收藏
分享

微信扫一扫

蓝桥杯31天冲刺之二十一 [java]

兽怪海北 2022-03-30 阅读 73

文章目录

最短路

image-20220328124856167

题目链接:https://www.lanqiao.cn/problems/609/learning/

img

修改数组

image-20220328132636311

题目链接:http://lx.lanqiao.cn/problem.page?gpid=T2734

package daily;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * http://lx.lanqiao.cn/problem.page?gpid=T2734
 * 
 * @author Jia
 *
 */
public class day3_28_2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ans = new int[N];
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < N; i++) {
			int num = sc.nextInt();
			while (set.contains(num)) {
				num++;
			}
			set.add(num);
			ans[i] = num;
		}
		sc.close();

		for (int i = 0; i < ans.length; i++) {
			System.out.print(ans[i] + " ");
		}
	}
}

游园安排

image-20220328132933311

题目链接:http://lx.lanqiao.cn/problem.page?gpid=T2873

举报

相关推荐

0 条评论