import java.util.*;class Main {    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        while (in.hasNext()) {            int n = in.nextInt();            int[] nums = new int[n];            for (int i = 0; i < n; i++) {                nums[i] = in.nextInt();            }            get(nums);        }        in.close();    }    public static void get(int[] nums) {        HashSet<Integer> set = new HashSet<>();        int n = nums.length;        int[] ans = new int[n];        for (int i = 0; i < n; i++) {            int j = i + 1;            int q = nums[i] % j;            int tp = j - q;            while (set.contains(tp)) {                tp += j;            }            set.add(tp);            ans[i] = tp;        }        for (int i = 0; i < n; i++) {            System.out.print(ans[i] + " ");        }    }}// 第二题class Main2 {    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        int num = in.nextInt();        int route = in.nextInt();        boolean[] isHuman = new boolean[num];        long[] nums = new long[num];        for (int i = 0; i < num; i++) {            String tp = in.next();            if (tp.equals("human")) {                isHuman[i] = true;            }            nums[i] = in.nextInt();        }        boolean[] deads = new boolean[num];        // 开始战斗        for (int i = 0; i < route; i++) {   // 输入好像有问题            try {                int a = in.nextInt() - 1;                int b = in.nextInt() - 1;                String ac = in.next();                String bc = in.next();                // 首先判断两方阵营相同不占斗                if (isHuman[a] == isHuman[b]) {                    continue;                }                // 一方死亡也不战斗                if (deads[a] || deads[b]) {                    continue;                }                // 判断是否战斗,切换人兽,a为人,b为兽                if (isHuman[b]) {                    int tp = a;                    a = b;                    b = tp;                    String tps = ac;                    ac = bc;                    bc = tps;                }                // 如果人公布角色                if ("Y".equals(ac)) {                    // 战斗                    if (nums[a] < nums[b]) {                        deads[a] = true;                    } else if (nums[a] == nums[b]) {                        deads[a] = true;                        deads[b] = true;                    } else {                        deads[b] = true;                    }                } else if ("Y".equals(bc)) {                    // 手公布角色                    if (nums[a] > nums[b]) {                        deads[b] = true;                    }                }            } catch (Exception ex) {                break;            }        }        for (int i = 0; i < num; i++) {            System.out.print(deads[i] ? "N" : "Y");        }    }}// 第三题class Main3 {    public static void main1(String[] args) {        Scanner in = new Scanner(System.in);        while (in.hasNext()) {            int n = in.nextInt();            int t = in.nextInt();            int[][] cost = new int[n][4];            for (int i = 0; i < n; i++) {                for (int j = 0; j < 4; j++) {                    cost[i][j] = in.nextInt();                }            }            get(cost, t);        }        in.close();    }    public static void get(int[][] cost, int t) {        // 01背包        // cost ct,cs,false,fs        int n = cost.length;        int[] old = new int[t + 1];        int[][] count = new int[n + 1][t + 1];        String[][] bi = new String[n + 1][t + 1];        for (int i = 0; i < n; i++) {            int[] news = new int[t + 1];            for (int j = 0; j <= t; j++) {                news[j] = old[j];                if (j >= cost[i][0]) {                    // 当前时间大于智力时间                    int score = old[j - cost[i][0]] + cost[i][1];                    int score1 = old[j - cost[i][2]] + cost[i][3];                    int max = Math.max(score, score1);                    if (max > old[j]) {                        news[j] = max;                        if (score > score1) {                            count[i][j] = j - cost[i][0];                            bi[i][j] = "A";                        } else {                            count[i][j] = j - cost[i][2];                            bi[i][j] = "B";                        }                    } else {                        count[i][j] = j;                        bi[i][j] = "F";                    }                } else if (j >= cost[i][2]) {                    // 当前大于暴力需要的时间                    int score = old[j - cost[i][2]] + cost[i][3];                    if (score > old[j]) {                        news[j] = score;                        count[i][j] = j - cost[i][2];                        bi[i][j] = "B";                    } else {                        count[i][j] = j;                        bi[i][j] = "F";                    }                } else {                    count[i][j] = j;                    bi[i][j] = "F";                }            }            old = news;        }        StringBuilder sb = new StringBuilder();        int idx = t;        for (int i = n - 1; i >= 0; i--) {            sb.append(bi[i][idx]);            idx = count[i][idx];        }        System.out.println(sb.reverse().toString());    }}
点赞 3
评论 0
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 15:58
投个小米提前批试试水,先投一个岗位看看形势,不行就再沉淀一下投第二个岗位,莫辜负
Java抽象带篮子:我嘞个骚刚,已经开始研发6g了吗
投递小米集团等公司9个岗位
点赞 评论 收藏
分享
Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
05-19 15:21
已编辑
门头沟学院 Java
白火同学:你才沟通了200,说实话,北上广深杭这里面你连一座城市的互联网公司都没投满呢,更别说还有各种准一线二线城市了。等你沟通突破了三位数,还没结果再考虑转行的事吧。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务