This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#define N 200501
#define NN 10000010
#define PB push_back
#define M ll(1e9 + 7)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define _ << " " <<
#define pri(x) cout << x << endl
#define endl '\n'
#define F first
#define S second
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef long double ld;
//typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
int n;
cin >> n;
ll x[n];
for (int i = 0; i < n; i++)
cin >> x[i];
for (int i = 1; i < n; i++, cout << endl)
for (int j = 0; j < i; j++)
{
if (x[i] % x[j] != 0)
{
cout << 1 << " ";
continue;
}
ll l, r;
for (int u = 0; u < 60; u++)
{
if (x[i] % (1ll << u) == 0)
l = u;
if (x[j] % (1ll << u) == 0)
r = u;
}
l = (1ll << l);
r = (1ll << r);
if (l / 4 == r / 4)
{
cout << 1 << " ";
}
else if (l / 16 == r / 16)
{
cout << 2 << " ";
}
else cout << 3 << " ";
}
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:69:22: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
69 | r = (1ll << r);
| ~~~~~^~~~~
Main.cpp:67:22: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
67 | l = (1ll << l);
| ~~~~~^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |