天天看點

「Nhk R1 B」Basement-er Without Wings

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int n;
void solve() {
    cin >> n;
    vector<int> a(n + 1), vis(n + 1);
    for (int i = 1; i <= n; i ++)
            a[i] = i;
    for (int i =1 ;i <= n; i ++) {
        int x;
        scanf("%d", & x);
        while(vis[a[x]]) a[x] += x;
        vis[a[x]] = 1;
        cout << a[x] << " ";
    }
    
}
int main(){
    int t;
    t = 1;
    while (t --) solve();
    return 0;
}      

繼續閱讀