#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
int n, arr[N], ans[N][N], dist[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++) cin >> arr[i];
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
if(arr[j] % arr[i] == 0){
dist[j] = max(dist[j], dist[i] + 1);
}
else ans[i][j] = 3;
}
}
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
if(ans[i][j] == 0){
if(dist[i] / 4 == dist[j] / 4) ans[i][j] = 1;
else if(dist[i] / 16 == dist[j] / 16) ans[i][j] = 2;
else ans[i][j] = 3;
}
}
}
for(int i = 2; i <= n; i++){
for(int j = 1; j < i; j++){
cout << ans[j][i] << " ";
}
cout << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 8 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 8 |
3 |
Halted |
0 ms |
0 KB |
- |