#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define _ << " " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long ll;
typedef std::pair<int, int> pii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;
const int MaxN = 2005;
const int Mod = 1e9 + 7;
int N;
ll x[MaxN];
int h[MaxN];
int c[MaxN][MaxN];
int height(ll a) {
assert(a >= 1);
return 63 -__builtin_clzll(a);
}
int color(int a, int b) {
assert(a < b);
assert(a >= 0 && b <= 60);
if (a / 4 == b / 4) return 1;
if (a / 16 == b / 16) return 2;
return 3;
}
void solve() {
REP(i, N) h[i] = height(x[i]);
REP(i, N) cerr << h[i] << " ";
cerr << endl << endl;
FOR(i, 1, N) {
REP(j, i) {
assert(x[i] != x[j]);
if (x[i] % x[j] == 0) {
c[i][j] = color(h[j], h[i]);
}
else {
c[i][j] = 1;
}
cout << c[i][j] << " ";
}
cout << endl;
}
}
void load() {
cin >> N;
REP(i, N) cin >> x[i];
}
int main() {
ios_base::sync_with_stdio(false);
load();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
51 ms |
7356 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
44 ms |
6508 KB |
Output is correct |
12 |
Correct |
52 ms |
7424 KB |
Output is correct |
13 |
Correct |
47 ms |
6764 KB |
Output is correct |
14 |
Correct |
4 ms |
1260 KB |
Output is correct |
15 |
Correct |
55 ms |
6764 KB |
Output is correct |
16 |
Correct |
46 ms |
6764 KB |
Output is correct |
17 |
Correct |
47 ms |
6764 KB |
Output is correct |
18 |
Correct |
46 ms |
6784 KB |
Output is correct |
19 |
Correct |
51 ms |
6788 KB |
Output is correct |
20 |
Correct |
46 ms |
6764 KB |
Output is correct |
21 |
Correct |
46 ms |
6892 KB |
Output is correct |
22 |
Correct |
49 ms |
6764 KB |
Output is correct |
23 |
Correct |
67 ms |
7276 KB |
Output is correct |