Untitled
#include <bits/stdc++.h> #define endl '\n' #define maxn 105 #define TASK bai1 #define For(i,a,b) for ( int i = a; i <= b; i++ ) #define MOD 100000000000007 using namespace std; int a[maxn],n,b[maxn],d = 0; void inp() { cin >> n; For(i,1,n) { cin >> a[i]; b[i] = n-i+1; } } void solve() { for(int i = n; i>=0; i--) { For(j,1,n) if (a[j] != 0) { d++; if(d % a[i] == 0) { cout << a[j] << " "; a[j] = 0; } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("bai1.inp","r")){ freopen("bai1.inp","r",stdin); } inp(); solve(); return 0; }
Leave a Comment