problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1010000000000000017LL; const ll MOD = 1000000007LL; #define REP(i, n) for (ll i = 0; i < n; i++) // #define DEBUG(fmt, ...) #define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__) int f(int n) { int count = 0; for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { if ((x * x + y * y + z * z + x * y + y * z + z * x) == n) { count++; } } } } return count; } int main() { std::cout << std::fixed << std::setprecision(10); ll N; cin >> N; for (int i = 1; i <= N; i++) { cout << f(i) << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1010000000000000017LL; const ll MOD = 1000000007LL; #define REP(i, n) for (ll i = 0; i < n; i++) // #define DEBUG(fmt, ...) #define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__) int f(int n) { int count = 0; for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { if ((x * x + y * y + z * z + x * y + y * z + z * x) == n) { count++; } else if ((x * x + y * y + z * z + x * y + y * z + z * x) > n) { break; } } } } return count; } int main() { std::cout << std::fixed << std::setprecision(10); ll N; cin >> N; for (int i = 1; i <= N; i++) { cout << f(i) << endl; } }
insert
19
19
19
21
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define PI 3.141592653589793238462643383279 #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) typedef long long int ll; typedef unsigned long long ull; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef pair<ll, ll> P; const long long MOD = 1e9 + 7; const ll INF = 1LL << 60; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int triplets(int x) { int cnt = 0; for (int i = 1; i <= (int)(1e2); i++) { for (int j = 1; j <= (int)(1e2); j++) { for (int k = 1; k <= (int)(1e2); k++) { if (i * i + j * j + k * k + i * j + j * k + k * i == x) cnt++; } } } return cnt; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cout << triplets(i) << endl; } }
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < n; ++i) #define all(v) v.begin(), v.end() #define PI 3.141592653589793238462643383279 #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) typedef long long int ll; typedef unsigned long long ull; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } typedef pair<ll, ll> P; const long long MOD = 1e9 + 7; const ll INF = 1LL << 60; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int triplets(int x) { int cnt = 0; for (int i = 1; i <= (int)(1e2); i++) { for (int j = 1; j <= (int)(1e2); j++) { for (int k = 1; k <= (int)(1e2); k++) { if (i * i + j * j + k * k + i * j + j * k + k * i > x) break; if (i * i + j * j + k * k + i * j + j * k + k * i == x) cnt++; } } } return cnt; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cout << triplets(i) << endl; } }
insert
34
34
34
36
TLE
p02608
C++
Time Limit Exceeded
// C - XYZ Triplets #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { ll n; cin >> n; ll sum = 0; vector<ll> ans(n, 0); for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { for (int z = 1; z <= n; z++) { sum = (x + y + z) * (x + y + z) - (x * y + y * z + z * x); if (sum > n) continue; ans[sum - 1]++; } } } rep(i, n) { cout << ans[i] << endl; } return 0; }
// C - XYZ Triplets #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { ll n; cin >> n; ll sum = 0; vector<ll> ans(n, 0); for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { for (int z = 1; z <= n; z++) { sum = (x + y + z) * (x + y + z) - (x * y + y * z + z * x); if (sum > n) break; ans[sum - 1]++; } } } rep(i, n) { cout << ans[i] << endl; } return 0; }
replace
16
17
16
17
TLE
p02608
C++
Runtime Error
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> ans(n, 0); for (int i = 1; i * i <= n; i++) for (int j = 1; j * j <= n; j++) for (int k = 1; k * k <= n; k++) { int f = i * i + j * j + k * k + i * j + j * k + k * i; ans[f - 1]++; } for (int i = 0; i < n; i++) cout << ans[i] << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> ans(n, 0); for (int i = 1; i * i <= n; i++) for (int j = 1; j * j <= n; j++) for (int k = 1; k * k <= n; k++) { long long f = i * i + j * j + k * k + i * j + j * k + k * i; if (f <= n) ans[f - 1]++; } for (int i = 0; i < n; i++) cout << ans[i] << endl; }
replace
17
19
17
20
-6
malloc(): corrupted top size
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; ll f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } int main() { ll N; cin >> N; for (int n = 1; n <= N; n++) { ll m = sqrt(n); int ans = 0; rep(x, m) rep(y, m) rep(z, m) { if (x == 0 || y == 0 || z == 0) continue; if (f(x, y, z) == n) ans++; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; ll f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } int main() { ll N; cin >> N; for (int n = 1; n <= N; n++) { ll m = sqrt(n); int ans = 0; int ans1 = 0; for (int x = 1; x <= m; x++) for (int y = x + 1; y <= m; y++) for (int z = y + 1; z <= m; z++) { if (x == 0 || y == 0 || z == 0) continue; ll res = f(x, y, z); if (res > n) break; if (res == n) ans1++; } ans += 6 * ans1; int ans2 = 0; for (int x = 1; x <= m; x++) for (int y = 1; y <= m; y++) { if (x == y) continue; ll res = x * x + 3 * y * y + 2 * x * y; if (res > n) break; if (res == n) ans2++; } ans += 3 * ans2; if (n % 6 == 0) { int ans3 = 0; for (int x = 1; x <= m; x++) { if (x * x == n / 6) ans3++; } ans += ans3; } cout << ans << endl; } return 0; }
replace
17
22
17
52
TLE
p02608
Python
Time Limit Exceeded
import math N = int(input()) for n in range(1, N + 1): count = 0 ub = int(math.sqrt(n)) for x in range(1, ub + 1): for y in range(x, ub + 1): for z in range(y, ub + 1): if x * x + y * y + z * z + x * y + y * z + z * x == n: s = len(set([x, y, z])) if s == 1: count += 1 elif s == 2: count += 3 else: count += 6 break print(count)
import math N = int(input()) for n in range(1, N + 1): count = 0 ub = int(math.sqrt(n)) for x in range(1, ub + 1): for y in range(x, ub + 1): r = 4 * n - 3 * x * x - 2 * x * y - 3 * y * y if r < 0: break z = (math.sqrt(r) - x - y) / 2 if z - int(z) < 1e-9: z = int(z) elif z - int(z + 1) < 1e-9: z = int(z + 1) else: break if y > z or z > ub: break if abs(x * x + y * y + z * z + x * y + y * z + z * x - n) < 1e-9: # print(x, y, round(z), z) s = len(set([x, y, round(z)])) if s == 1: count += 1 elif s == 2: count += 3 else: count += 6 print(count)
replace
9
19
9
32
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; int main(void) { int N; cin >> N; vector<int> ans(N + 1); for (int x = 1; x <= 101; x++) { for (int y = 1; y <= 101; y++) { for (int z = 1; z <= 101; z++) { int tmp = x * x + y * y + z * z + x * y + y * z + z * x; ans[tmp]++; } } } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; int main(void) { int N; cin >> N; vector<int> ans(200000); for (int x = 1; x <= 101; x++) { for (int y = 1; y <= 101; y++) { for (int z = 1; z <= 101; z++) { int tmp = x * x + y * y + z * z + x * y + y * z + z * x; ans[tmp]++; } } } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } return 0; }
replace
8
9
8
9
-11
p02608
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; i++) { int pp = 0; int as = sqrt(i); for (int a = 1; a < as; a++) { for (int b = 1; b < as; b++) { for (int c = 1; c < as; c++) { if (a * a + b * b + c * c + a * b + a * c + b * c == i) { pp++; break; } } } } cout << pp << endl; } return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; i++) { int pp = 0; int as = sqrt(i); for (int a = 1; a < as; a++) { for (int b = 1; b < as; b++) { double ji = (-1 * (a + b) + sqrt(1.0 * (a + b) * (a + b) - 4.0 * (a * a + b * b + a * b - i))) / 2; double jii = (-1 * (a + b) - sqrt(1.0 * (a + b) * (a + b) - 4.0 * (a * a + b * b + a * b - i))) / 2; if (ji - (int)ji == 0 && ji > 0 || jii - (int)jii == 0 && jii > 0) { pp++; // break; } } } cout << pp << endl; } return 0; }
replace
12
17
12
21
TLE
p02608
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> int main() { int n; std::cin >> n; std::vector<int> a(n + 1, 0); for (int x = 1; x < n / 2; x++) { for (int y = 1; y < n / 2; y++) { for (int z = 1; z < n / 2; z++) { int value = x * x + y * y + z * z + x * y + y * z + z * x; if (value <= n) ++a[value]; } } } for (int i = 1; i <= n; i++) { std::cout << a[i] << '\n'; } return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> int main() { int n; std::cin >> n; std::vector<int> a(n + 1, 0); for (int x = 1; x < 100; x++) { for (int y = 1; y < 100; y++) { for (int z = 1; z < 100; z++) { int value = x * x + y * y + z * z + x * y + y * z + z * x; if (value <= n) ++a[value]; } } } for (int i = 1; i <= n; i++) { std::cout << a[i] << '\n'; } return 0; }
replace
9
12
9
12
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // defines... #define ll long long #define tata return; #define pb push_back #define mp make_pair #define in insert #define run \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define yes cout << "YES" << endl; #define no cout << "NO" << endl; #define vec vector<ll> #define setl set<ll> #define mapl map<ll, ll> #define shunno cout << 0 << endl; #define pi 2 * acos(0.0) 1 #define hobena cout << -1 << endl; // typedefs... typedef pair<ll, ll> pll; // const.. // const ll fx[]={0,1,0,-1}; // const ll fy[]={1,0,-1,0}; const ll mod = 1e9 + 7; //......Algo..... /*ll ncr(ll n, ll k) { ll res = 1; if (k > n - k) k = n - k; for (int i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); } return res; } */ // to remove suffix of a number from a set of string /* for(int k=1; k<j.size(); k++) if(temp.count(string(j.begin()+k,j.end()))) temp.erase(string(j.begin()+k,j.end())); */ ll bigmod(ll base, ll power, ll mod) { if (power == 0) return 1; else if (power % 2) { ll p1 = base % mod; ll p2 = (bigmod(base, power - 1, mod)) % mod; return (p1 * p2) % mod; } else { ll p = (bigmod(base, power / 2, mod) % mod); return (p * p) % mod; } } ll dp[1000000]; void oka() { memset(dp, 0, sizeof dp); ll n, i, j, k; cin >> n; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { for (k = 1; k <= n; k++) { dp[i * i + j * j + k * k + i * j + i * k + j * k]++; } } } for (i = 1; i <= n; i++) { cout << dp[i] << endl; } } /*I'll paint it on the walls cause I'm the one at fault I'll never fight again and this is how it ends .*/ int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); run ll t; t = 1; // cin>>t; while (t--) { oka(); } }
#include <bits/stdc++.h> using namespace std; // defines... #define ll long long #define tata return; #define pb push_back #define mp make_pair #define in insert #define run \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define yes cout << "YES" << endl; #define no cout << "NO" << endl; #define vec vector<ll> #define setl set<ll> #define mapl map<ll, ll> #define shunno cout << 0 << endl; #define pi 2 * acos(0.0) 1 #define hobena cout << -1 << endl; // typedefs... typedef pair<ll, ll> pll; // const.. // const ll fx[]={0,1,0,-1}; // const ll fy[]={1,0,-1,0}; const ll mod = 1e9 + 7; //......Algo..... /*ll ncr(ll n, ll k) { ll res = 1; if (k > n - k) k = n - k; for (int i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); } return res; } */ // to remove suffix of a number from a set of string /* for(int k=1; k<j.size(); k++) if(temp.count(string(j.begin()+k,j.end()))) temp.erase(string(j.begin()+k,j.end())); */ ll bigmod(ll base, ll power, ll mod) { if (power == 0) return 1; else if (power % 2) { ll p1 = base % mod; ll p2 = (bigmod(base, power - 1, mod)) % mod; return (p1 * p2) % mod; } else { ll p = (bigmod(base, power / 2, mod) % mod); return (p * p) % mod; } } ll dp[1000000]; void oka() { memset(dp, 0, sizeof dp); ll n, i, j, k; cin >> n; for (i = 1; i <= 100; i++) { for (j = 1; j <= 100; j++) { for (k = 1; k <= 100; k++) { dp[i * i + j * j + k * k + i * j + i * k + j * k]++; } } } for (i = 1; i <= n; i++) { cout << dp[i] << endl; } } /*I'll paint it on the walls cause I'm the one at fault I'll never fight again and this is how it ends .*/ int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); run ll t; t = 1; // cin>>t; while (t--) { oka(); } }
replace
72
75
72
75
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> // Begin Header {{{ using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < n; i++) #define loop(i, j, n) for (ll i = j; i < n; i++) #define all(x) (x).begin(), (x).end() constexpr int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const long double PI = acos(-1); // }}} End Header int main() { ll n; cin >> n; vector<ll> a(n + 1); loop(x, 1, n) { loop(y, 1, n) { loop(z, 1, n) { ll cnt; cnt = x * x + y * y + z * z + x * y + y * z + z * x; if (cnt > n) continue; a[cnt]++; } } } loop(i, 1, n + 1) { cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> // Begin Header {{{ using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i, n) for (ll i = 0; i < n; i++) #define loop(i, j, n) for (ll i = j; i < n; i++) #define all(x) (x).begin(), (x).end() constexpr int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const long double PI = acos(-1); // }}} End Header int main() { ll n; cin >> n; vector<ll> a(n + 1); for (ll x = 1; x * x <= n; x++) { for (ll y = 1; y * y <= n; y++) { for (ll z = 1; z * z <= n; z++) { ll cnt = x * x + y * y + z * z + x * y + y * z + z * x; if (cnt > n) continue; a[cnt]++; } } } loop(i, 1, n + 1) { cout << a[i] << endl; } return 0; }
replace
17
22
17
21
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } int count(int n) { int res = 0; for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { if (f(x, y, z) == n) res++; } } } return res; } int main() { int N; cin >> N; for (int i = 1; i <= N; i++) cout << count(i) << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } int count(int n) { int res = 0; for (int x = 1; x <= 100; x++) { for (int y = x; y <= 100; y++) { for (int z = y; z <= 100; z++) { if (f(x, y, z) == n) { if (x == y && y == z) res++; if (x != y && y != z && z != x) res += 6; if (x == y && y != z) res += 3; if (y == z && x != z) res += 3; if (x == z && x != y) res += 3; } } } } return res; } int main() { int N; cin >> N; for (int i = 1; i <= N; i++) cout << count(i) << endl; return 0; }
replace
13
17
13
27
TLE
p02608
C++
Time Limit Exceeded
/* Code by - Navneet Lohia */ #include <bits/stdc++.h> using namespace std; #define int ll #define ll long long #define ull unsigned long long #define vi vector<int> #define pii pair<int, int> #define uii unordered_map<int, int> #define endl "\n" #define pb push_back #define mp make_pair #define fr(i, a, n) for (int i = a; i < n; i++) #define rf(i, a, n) for (int i = n - 1; i >= a; i--) #define tt(x) \ int x; \ cin >> x; \ while (x--) #define t(x) \ int x = 1; \ while (x--) #define input(a, n) \ for (int i = 0; i < n; i++) { \ int x; \ cin >> x; \ a[i] = x; \ } #define print(a, n) \ for (int i = 0; i < n; i++) { \ cout << a[i] << " "; \ } \ cout << endl; #define Print(a) \ for (auto it = a.begin(); it != a.end(); it++) { \ cout << *it << " "; \ } \ cout << endl; #define ps(x, y) fixed << setprecision(y) << x #define PI 3.1415926536 // Returns count of subarrays of arr with XOR // value equals to m long long subarrayXor(int arr[], int n, int m) { long long ans = 0; // Initialize answer to be returned // Create a prefix xor-sum array such that // xorArr[i] has value equal to XOR // of all elements in arr[0 ..... i] int *xorArr = new int[n]; // Create map that stores number of prefix array // elements corresponding to a XOR value unordered_map<int, int> mp; // Initialize first element of prefix array xorArr[0] = arr[0]; // Computing the prefix array. for (int i = 1; i < n; i++) xorArr[i] = xorArr[i - 1] ^ arr[i]; // Calculate the answer for (int i = 0; i < n; i++) { // Find XOR of current prefix with m. int tmp = m ^ xorArr[i]; // If above XOR exists in map, then there // is another previous prefix with same // XOR, i.e., there is a subarray ending // at i with XOR equal to m. ans = ans + ((long long)mp[tmp]); // If this subarray has XOR equal to m itself. if (xorArr[i] == m) ans++; // Add the XOR of this subarray to the map mp[xorArr[i]]++; } // Return total count of subarrays having XOR of // elements as given value m return ans; } // Function for extended Euclidean Algorithm int gcdExtended(int a, int b, int *x, int *y) { // Base Case if (a == 0) { *x = 0; *y = 1; return b; } int x1, y1; // To store results of recursive call int gcd = gcdExtended(b % a, a, &x1, &y1); // Update x and y using results of // recursive call *x = y1 - (b / a) * x1; *y = x1; return gcd; } // ax + by = c (Linear Diophantine equation) bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) { g = gcdExtended(abs(a), abs(b), &x0, &y0); if (c % g) { return false; } x0 *= c / g; y0 *= c / g; if (a < 0) x0 = -x0; if (b < 0) y0 = -y0; return true; } int maxContiguousSubArray(int *A, int n) { int max_so_far = A[0]; int curr_max = A[0]; for (int i = 1; i < n; i++) { curr_max = max(A[i], curr_max + A[i]); max_so_far = max(max_so_far, curr_max); } return max_so_far; } int NcR(int n, int r) { // p holds the value of n*(n-1)*(n-2)..., // k holds the value of r*(r-1)... long long p = 1, k = 1; // C(n, r) == C(n, n-r), // choosing the smaller value if (n - r < r) r = n - r; if (r != 0) { while (r) { p *= n; k *= r; // gcd of p, k long long m = __gcd(p, k); // dividing by gcd, to simplify product // division by their gcd saves from the overflow p /= m; k /= m; n--; r--; } // k should be simplified to 1 // as C(n, r) is a natural number // (denominator should be 1 ) . } else p = 1; // if our approach is correct p = ans and k =1 return p; } int power(int x, int y) { if (y == 0) return 1; int temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } int power(int x, int y, int p) { int res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } // This functions finds all primes smaller than 'limit' // using simple sieve of eratosthenes. It also stores // found primes in vector prime[] vi simpleSieve(int limit) { // Create a boolean array "mark[0..n-1]" and initialize // all entries of it as true. A value in mark[p] will // finally be false if 'p' is Not a prime, else true. bool mark[limit + 1]; memset(mark, true, sizeof(mark)); vi prime; for (int p = 2; p * p < limit; p++) { // If p is not changed, then it is a prime if (mark[p] == true) { // Update all multiples of p for (int i = p * 2; i < limit; i += p) mark[i] = false; } } // Print all prime numbers and store them in prime for (int p = 2; p < limit; p++) { if (mark[p] == true) { prime.push_back(p); } } return prime; } // Prints all prime numbers smaller than 'n' vi segmentedSieve(int n) { // Compute all primes smaller than or equal // to square root of n using simple sieve int limit = floor(sqrt(n)) + 1; vector<int> prime = simpleSieve(limit); vi ans(prime); // Divide the range [0..n-1] in different segments // We have chosen segment size as sqrt(n). int low = limit; int high = 2 * limit; // While all segments of range [0..n-1] are not processed, // process one segment at a time while (low < n) { if (high >= n) high = n; // To mark primes in current range. A value in mark[i] // will finally be false if 'i-low' is Not a prime, // else true. bool mark[limit + 1]; memset(mark, true, sizeof(mark)); // Use the found primes by simpleSieve() to find // primes in current range for (int i = 0; i < prime.size(); i++) { // Find the minimum number in [low..high] that is // a multiple of prime[i] (divisible by prime[i]) // For example, if low is 31 and prime[i] is 3, // we start with 33. int loLim = floor(low / prime[i]) * prime[i]; if (loLim < low) loLim += prime[i]; /* Mark multiples of prime[i] in [low..high]: We are marking j - low for j, i.e. each number in range [low, high] is mapped to [0, high-low] so if range is [50, 100] marking 50 corresponds to marking 0, marking 51 corresponds to 1 and so on. In this way we need to allocate space only for range */ for (int j = loLim; j < high; j += prime[i]) mark[j - low] = false; } // Numbers which are not marked as false are prime for (int i = low; i < high; i++) if (mark[i - low] == true) ans.pb(i); // Update low and high for next segment low = low + limit; high = high + limit; } return ans; } int modInverse(int n, int p) { return power(n, p - 2, p); } // Returns n^(-1) mod p int nCrModPFermat(int n, int r, int p) { // Base case if (r == 0) return 1; // Fill factorial array so that we // can find all factorial of r, n // and n-r int fac[n + 1]; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } // Returns nCr % p using Fermat's little theorem int fact(int n) { if ((n == 0) || (n == 1)) return 1; else return n * fact(n - 1); } bool isPrime(int num) { bool flag = true; for (int i = 2; i <= sqrt(num); i++) { if (num % i == 0) { flag = false; break; } } return flag; } bool isPalindrome(string str) { int i = 0, j = str.size() - 1; while (i < j) { if (str[i] != str[j]) return false; i++, j--; } return true; } bool isVowel(char ch) { ch = tolower(ch); if (ch == 'a' or ch == 'i' or ch == 'e' or ch == 'o' or ch == 'u') return true; return false; } bool comp(pii &a, pii &b) { if (a.first > b.first) return true; else if (a.first < b.first) return false; if (a.second > b.second) return false; return true; } int seg[400004], ar[100001]; // for segment trees segment array and input array if N = 10^5 // function for segment tree construction void build_segTree_min_max(int segIndex, int segStart, int segEnd) { if (segStart == segEnd) { seg[segIndex] = ar[segStart]; return; } int mid = (segStart + segEnd) / 2; build_segTree_min_max(2 * segIndex, segStart, mid); build_segTree_min_max(2 * segIndex + 1, mid + 1, segEnd); seg[segIndex] = max(seg[2 * segIndex], seg[2 * segIndex + 1]); } // query function for segment tree int query_segTree(int segIndex, int segStart, int segEnd, int queryStart, int queryEnd) { if (segEnd < queryStart or segStart > queryEnd) return INT_MIN; // out of range if (segStart >= queryStart and segEnd <= queryEnd) return seg[segIndex]; // complete in range int mid = (segStart + segEnd) / 2; return max( query_segTree(2 * segIndex, segStart, mid, queryStart, queryEnd), query_segTree(2 * segIndex + 1, mid + 1, segEnd, queryStart, queryEnd)); } // update function for segment tree void update_segTree(int segIndex, int segStart, int segEnd, int queryIndex) { if (segStart == segEnd) // reached the leaf node / query index { seg[segIndex] = ar[queryIndex]; return; } int mid = (segStart + segEnd) / 2; if (queryIndex <= mid) update_segTree(2 * segIndex, segStart, mid, queryIndex); else update_segTree(2 * segIndex + 1, mid + 1, segEnd, queryIndex); seg[segIndex] = min(seg[2 * segIndex], seg[2 * segIndex + 1]); } // Returns sum of arr[0..index]. This function assumes // that the array is preprocessed and partial sums of // array elements are stored in BITree[]. int getSum(int BITree[], int index) { int sum = 0; // Iniialize result // index in BITree[] is 1 more than the index in arr[] index = index + 1; // Traverse ancestors of BITree[index] while (index > 0) { // Add current element of BITree to sum sum += BITree[index]; // Move index to parent node in getSum View index -= index & (-index); } return sum; } // Updates a node in Binary Index Tree (BITree) at given index // in BITree. The given value 'val' is added to BITree[i] and // all of its ancestors in tree. void updateBIT(int BITree[], int n, int index, int val) { // index in BITree[] is 1 more than the index in arr[] index = index + 1; // Traverse all ancestors and add 'val' while (index <= n) { // Add 'val' to current node of BI Tree BITree[index] += val; // Update index to that of parent in update View index += index & (-index); } } // Constructs and returns a Binary Indexed Tree for given // array of size n. int *constructBITree(int arr[], int n) { // Create and initialize BITree[] as 0 int *BITree = new int[n + 1]; for (int i = 1; i <= n; i++) BITree[i] = 0; // Store the actual values in BITree[] using update() for (int i = 0; i < n; i++) updateBIT(BITree, n, i, arr[i]); // Uncomment below lines to see contents of BITree[] // for (int i=1; i<=n; i++) // cout << BITree[i] << " "; return BITree; } int min(int a, int b) { if (a < b) return a; return b; } void test_case() { int n; cin >> n; fr(i, 1, n + 1) { int ans = 0; fr(x, 1, i) { fr(y, 1, i) { int b = x + y; int D = 4 * i - 3 * x * x - 3 * y * y - 2 * x * y; int rootD = sqrt(D); if (rootD * rootD == D and rootD > b) { int num = rootD - b; if (num % 2 == 0) { num /= 2; ans++; } } } } cout << ans << endl; } } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif t(x) { test_case(); } return 0; }
/* Code by - Navneet Lohia */ #include <bits/stdc++.h> using namespace std; #define int ll #define ll long long #define ull unsigned long long #define vi vector<int> #define pii pair<int, int> #define uii unordered_map<int, int> #define endl "\n" #define pb push_back #define mp make_pair #define fr(i, a, n) for (int i = a; i < n; i++) #define rf(i, a, n) for (int i = n - 1; i >= a; i--) #define tt(x) \ int x; \ cin >> x; \ while (x--) #define t(x) \ int x = 1; \ while (x--) #define input(a, n) \ for (int i = 0; i < n; i++) { \ int x; \ cin >> x; \ a[i] = x; \ } #define print(a, n) \ for (int i = 0; i < n; i++) { \ cout << a[i] << " "; \ } \ cout << endl; #define Print(a) \ for (auto it = a.begin(); it != a.end(); it++) { \ cout << *it << " "; \ } \ cout << endl; #define ps(x, y) fixed << setprecision(y) << x #define PI 3.1415926536 // Returns count of subarrays of arr with XOR // value equals to m long long subarrayXor(int arr[], int n, int m) { long long ans = 0; // Initialize answer to be returned // Create a prefix xor-sum array such that // xorArr[i] has value equal to XOR // of all elements in arr[0 ..... i] int *xorArr = new int[n]; // Create map that stores number of prefix array // elements corresponding to a XOR value unordered_map<int, int> mp; // Initialize first element of prefix array xorArr[0] = arr[0]; // Computing the prefix array. for (int i = 1; i < n; i++) xorArr[i] = xorArr[i - 1] ^ arr[i]; // Calculate the answer for (int i = 0; i < n; i++) { // Find XOR of current prefix with m. int tmp = m ^ xorArr[i]; // If above XOR exists in map, then there // is another previous prefix with same // XOR, i.e., there is a subarray ending // at i with XOR equal to m. ans = ans + ((long long)mp[tmp]); // If this subarray has XOR equal to m itself. if (xorArr[i] == m) ans++; // Add the XOR of this subarray to the map mp[xorArr[i]]++; } // Return total count of subarrays having XOR of // elements as given value m return ans; } // Function for extended Euclidean Algorithm int gcdExtended(int a, int b, int *x, int *y) { // Base Case if (a == 0) { *x = 0; *y = 1; return b; } int x1, y1; // To store results of recursive call int gcd = gcdExtended(b % a, a, &x1, &y1); // Update x and y using results of // recursive call *x = y1 - (b / a) * x1; *y = x1; return gcd; } // ax + by = c (Linear Diophantine equation) bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) { g = gcdExtended(abs(a), abs(b), &x0, &y0); if (c % g) { return false; } x0 *= c / g; y0 *= c / g; if (a < 0) x0 = -x0; if (b < 0) y0 = -y0; return true; } int maxContiguousSubArray(int *A, int n) { int max_so_far = A[0]; int curr_max = A[0]; for (int i = 1; i < n; i++) { curr_max = max(A[i], curr_max + A[i]); max_so_far = max(max_so_far, curr_max); } return max_so_far; } int NcR(int n, int r) { // p holds the value of n*(n-1)*(n-2)..., // k holds the value of r*(r-1)... long long p = 1, k = 1; // C(n, r) == C(n, n-r), // choosing the smaller value if (n - r < r) r = n - r; if (r != 0) { while (r) { p *= n; k *= r; // gcd of p, k long long m = __gcd(p, k); // dividing by gcd, to simplify product // division by their gcd saves from the overflow p /= m; k /= m; n--; r--; } // k should be simplified to 1 // as C(n, r) is a natural number // (denominator should be 1 ) . } else p = 1; // if our approach is correct p = ans and k =1 return p; } int power(int x, int y) { if (y == 0) return 1; int temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } int power(int x, int y, int p) { int res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } // This functions finds all primes smaller than 'limit' // using simple sieve of eratosthenes. It also stores // found primes in vector prime[] vi simpleSieve(int limit) { // Create a boolean array "mark[0..n-1]" and initialize // all entries of it as true. A value in mark[p] will // finally be false if 'p' is Not a prime, else true. bool mark[limit + 1]; memset(mark, true, sizeof(mark)); vi prime; for (int p = 2; p * p < limit; p++) { // If p is not changed, then it is a prime if (mark[p] == true) { // Update all multiples of p for (int i = p * 2; i < limit; i += p) mark[i] = false; } } // Print all prime numbers and store them in prime for (int p = 2; p < limit; p++) { if (mark[p] == true) { prime.push_back(p); } } return prime; } // Prints all prime numbers smaller than 'n' vi segmentedSieve(int n) { // Compute all primes smaller than or equal // to square root of n using simple sieve int limit = floor(sqrt(n)) + 1; vector<int> prime = simpleSieve(limit); vi ans(prime); // Divide the range [0..n-1] in different segments // We have chosen segment size as sqrt(n). int low = limit; int high = 2 * limit; // While all segments of range [0..n-1] are not processed, // process one segment at a time while (low < n) { if (high >= n) high = n; // To mark primes in current range. A value in mark[i] // will finally be false if 'i-low' is Not a prime, // else true. bool mark[limit + 1]; memset(mark, true, sizeof(mark)); // Use the found primes by simpleSieve() to find // primes in current range for (int i = 0; i < prime.size(); i++) { // Find the minimum number in [low..high] that is // a multiple of prime[i] (divisible by prime[i]) // For example, if low is 31 and prime[i] is 3, // we start with 33. int loLim = floor(low / prime[i]) * prime[i]; if (loLim < low) loLim += prime[i]; /* Mark multiples of prime[i] in [low..high]: We are marking j - low for j, i.e. each number in range [low, high] is mapped to [0, high-low] so if range is [50, 100] marking 50 corresponds to marking 0, marking 51 corresponds to 1 and so on. In this way we need to allocate space only for range */ for (int j = loLim; j < high; j += prime[i]) mark[j - low] = false; } // Numbers which are not marked as false are prime for (int i = low; i < high; i++) if (mark[i - low] == true) ans.pb(i); // Update low and high for next segment low = low + limit; high = high + limit; } return ans; } int modInverse(int n, int p) { return power(n, p - 2, p); } // Returns n^(-1) mod p int nCrModPFermat(int n, int r, int p) { // Base case if (r == 0) return 1; // Fill factorial array so that we // can find all factorial of r, n // and n-r int fac[n + 1]; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } // Returns nCr % p using Fermat's little theorem int fact(int n) { if ((n == 0) || (n == 1)) return 1; else return n * fact(n - 1); } bool isPrime(int num) { bool flag = true; for (int i = 2; i <= sqrt(num); i++) { if (num % i == 0) { flag = false; break; } } return flag; } bool isPalindrome(string str) { int i = 0, j = str.size() - 1; while (i < j) { if (str[i] != str[j]) return false; i++, j--; } return true; } bool isVowel(char ch) { ch = tolower(ch); if (ch == 'a' or ch == 'i' or ch == 'e' or ch == 'o' or ch == 'u') return true; return false; } bool comp(pii &a, pii &b) { if (a.first > b.first) return true; else if (a.first < b.first) return false; if (a.second > b.second) return false; return true; } int seg[400004], ar[100001]; // for segment trees segment array and input array if N = 10^5 // function for segment tree construction void build_segTree_min_max(int segIndex, int segStart, int segEnd) { if (segStart == segEnd) { seg[segIndex] = ar[segStart]; return; } int mid = (segStart + segEnd) / 2; build_segTree_min_max(2 * segIndex, segStart, mid); build_segTree_min_max(2 * segIndex + 1, mid + 1, segEnd); seg[segIndex] = max(seg[2 * segIndex], seg[2 * segIndex + 1]); } // query function for segment tree int query_segTree(int segIndex, int segStart, int segEnd, int queryStart, int queryEnd) { if (segEnd < queryStart or segStart > queryEnd) return INT_MIN; // out of range if (segStart >= queryStart and segEnd <= queryEnd) return seg[segIndex]; // complete in range int mid = (segStart + segEnd) / 2; return max( query_segTree(2 * segIndex, segStart, mid, queryStart, queryEnd), query_segTree(2 * segIndex + 1, mid + 1, segEnd, queryStart, queryEnd)); } // update function for segment tree void update_segTree(int segIndex, int segStart, int segEnd, int queryIndex) { if (segStart == segEnd) // reached the leaf node / query index { seg[segIndex] = ar[queryIndex]; return; } int mid = (segStart + segEnd) / 2; if (queryIndex <= mid) update_segTree(2 * segIndex, segStart, mid, queryIndex); else update_segTree(2 * segIndex + 1, mid + 1, segEnd, queryIndex); seg[segIndex] = min(seg[2 * segIndex], seg[2 * segIndex + 1]); } // Returns sum of arr[0..index]. This function assumes // that the array is preprocessed and partial sums of // array elements are stored in BITree[]. int getSum(int BITree[], int index) { int sum = 0; // Iniialize result // index in BITree[] is 1 more than the index in arr[] index = index + 1; // Traverse ancestors of BITree[index] while (index > 0) { // Add current element of BITree to sum sum += BITree[index]; // Move index to parent node in getSum View index -= index & (-index); } return sum; } // Updates a node in Binary Index Tree (BITree) at given index // in BITree. The given value 'val' is added to BITree[i] and // all of its ancestors in tree. void updateBIT(int BITree[], int n, int index, int val) { // index in BITree[] is 1 more than the index in arr[] index = index + 1; // Traverse all ancestors and add 'val' while (index <= n) { // Add 'val' to current node of BI Tree BITree[index] += val; // Update index to that of parent in update View index += index & (-index); } } // Constructs and returns a Binary Indexed Tree for given // array of size n. int *constructBITree(int arr[], int n) { // Create and initialize BITree[] as 0 int *BITree = new int[n + 1]; for (int i = 1; i <= n; i++) BITree[i] = 0; // Store the actual values in BITree[] using update() for (int i = 0; i < n; i++) updateBIT(BITree, n, i, arr[i]); // Uncomment below lines to see contents of BITree[] // for (int i=1; i<=n; i++) // cout << BITree[i] << " "; return BITree; } int min(int a, int b) { if (a < b) return a; return b; } void test_case() { int n; cin >> n; fr(i, 1, n + 1) { int ans = 0; fr(x, 1, sqrt(i) + 1) { fr(y, 1, sqrt(i) + 1) { int b = x + y; int D = 4 * i - 3 * x * x - 3 * y * y - 2 * x * y; int rootD = sqrt(D); if (rootD * rootD == D and rootD > b) { int num = rootD - b; if (num % 2 == 0) { num /= 2; ans++; } } } } cout << ans << endl; } } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif t(x) { test_case(); } return 0; }
replace
478
480
478
480
TLE
p02608
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; int n, m, ans, f[1005]; int coun(int x, int y, int z) { return x == y && y == z ? 1 : 3; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); scanf("%d", &n); m = sqrt(n); for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = j; k <= m; k++) { int p = i * i + j * j + k * k + i * j + i * k + j * k; if (p > n) continue; f[p] += coun(i, j, k); } for (int i = 1; i <= n; i++) printf("%d\n", f[i]); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; int n, m, ans, f[10005]; int coun(int x, int y, int z) { if (x == y && y == z) return 1; if (x == y || y == z) return 3; return 6; } int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); scanf("%d", &n); m = sqrt(n); for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = j; k <= m; k++) { int p = i * i + j * j + k * k + i * j + i * k + j * k; if (p > n) continue; f[p] += coun(i, j, k); } for (int i = 1; i <= n; i++) printf("%d\n", f[i]); return 0; }
replace
9
11
9
17
0
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { int b = i * i + j * j + k * k + i * j + j * k + k * i; if (b <= N) { a.at(b)++; } } } } for (int i = 1; i <= N; i++) { cout << a.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N + 1); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { int b = i * i + j * j + k * k + i * j + j * k + k * i; if (b <= N) { a.at(b)++; } } } } for (int i = 1; i <= N; i++) { cout << a.at(i) << endl; } }
replace
6
7
6
7
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 20) >= this->size() (which is 20)
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int fun(int N) { int count = 0; int m = N / 2; for (int i = 1; i <= m; i++) { for (int j = 1; j <= i; j++) { for (int k = 1; k <= j; k++) { int A = i + j + k; if (A * A - i * j - j * k - k * i == N) { int t = 0; if (i == j) { t += 1; } if (i == k) { t += 1; } if (j == k) { t += 1; } if (t == 0) { count += 6; } else if (t == 1) { count += 3; } else { count += 1; } } } } } return count; } int main() { int N; cin >> N; for (int i = 1; i <= N; i++) { cout << fun(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int fun(int N) { int count = 0; int m = int(sqrt(N)) + 1; for (int i = 1; i <= m; i++) { for (int j = 1; j <= i; j++) { for (int k = 1; k <= j; k++) { int A = i + j + k; if (A * A - i * j - j * k - k * i == N) { int t = 0; if (i == j) { t += 1; } if (i == k) { t += 1; } if (j == k) { t += 1; } if (t == 0) { count += 6; } else if (t == 1) { count += 3; } else { count += 1; } } } } } return count; } int main() { int N; cin >> N; for (int i = 1; i <= N; i++) { cout << fun(i) << endl; } }
replace
5
6
5
6
TLE
p02608
C++
Runtime Error
#include <cstdio> using namespace std; int n, tmp, Ans[1010]; int main() { scanf("%d", &n); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int k = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z); if (k <= n) Ans[k]++; } } } for (int i = 1; i <= n; i++) { printf("%d\n", Ans[i]); } return 0; }
#include <cstdio> using namespace std; int n, tmp, Ans[10010]; int main() { scanf("%d", &n); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int k = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z); if (k <= n) Ans[k]++; } } } for (int i = 1; i <= n; i++) { printf("%d\n", Ans[i]); } return 0; }
replace
3
4
3
4
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define reps(i, n) for (ll i = 1; i <= (n); ++i) #define _rep(i, n) for (ll i = (n)-1; i >= 0; --i) #define _reps(i, n) for (ll i = n; i > 0; --i) #define all(x) (x).begin(), (x).end() #define _all(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; using P = pair<ll, ll>; int main(void) { ll n; cin >> n; reps(i, n) { ll cnt = 0; for (ll x = 1; x * x < i; x++) { for (ll y = 1; ((x * x) + (y * y)) < i; y++) { for (ll z = 1; ((x * x) + (y * y) + (z * z)) < i; z++) { if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i) { cnt++; } } } } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define reps(i, n) for (ll i = 1; i <= (n); ++i) #define _rep(i, n) for (ll i = (n)-1; i >= 0; --i) #define _reps(i, n) for (ll i = n; i > 0; --i) #define all(x) (x).begin(), (x).end() #define _all(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; using P = pair<ll, ll>; int main(void) { ll n; cin >> n; reps(i, n) { ll cnt = 0; for (ll x = 1; x * x < i; x++) { for (ll y = 1; ((x * x) + (y * y) + (x * y)) < i; y++) { for (ll z = 1; ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) <= i; z++) { if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i) { cnt++; } } } } cout << cnt << endl; } return 0; }
replace
20
22
20
25
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = a; i < (b + a); i++) #define W1 while (1) #define COUT(x) cout << x << endl using namespace std; using ll = long long; using ld = long double; #define ALL(x) x.begin(), x.end() #define P pair<int, int> #define mod 1000000007 #define PB push_back #define F first #define S second int main() { int n; cin >> n; vector<int> f(n + 1, 0); for (int i = 1; i * i <= n; i++) { for (int j = 1; j * j <= n; j++) { for (int k = 1; k * k <= n; k++) { int num = i * i + j * j + k * k + i * j + j * k + k * i; f[num]++; } } } FOR(i, 1, n) { COUT(f[i]); } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = a; i < (b + a); i++) #define W1 while (1) #define COUT(x) cout << x << endl using namespace std; using ll = long long; using ld = long double; #define ALL(x) x.begin(), x.end() #define P pair<int, int> #define mod 1000000007 #define PB push_back #define F first #define S second int main() { int n; cin >> n; vector<int> f(n + 1, 0); for (int i = 1; i * i <= n; i++) { for (int j = 1; j * j <= n; j++) { for (int k = 1; k * k <= n; k++) { int num = i * i + j * j + k * k + i * j + j * k + k * i; if (f.size() - 1 < num) continue; f[num]++; } } } FOR(i, 1, n) { COUT(f[i]); } return 0; }
insert
23
23
23
25
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 1; i * i <= (int)(n); i++) int main() { int MAX_N = 10002; int s[MAX_N]; for (int i = 0; i < MAX_N; ++i) s[i] = 0; for (int i = 0; i < MAX_N; ++i) { rep(j, i) { rep(k, i) { rep(l, i) { if (j * j + k * k + l * l + j * k + k * l + l * j == i) ++s[i]; } } } } int n; cin >> n; for (int i = 1; i <= n; ++i) cout << s[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 1; i * i <= (int)(n); i++) int main() { int MAX_N = 10002; int s[MAX_N]; for (int i = 0; i < MAX_N; ++i) s[i] = 0; for (int i = 0; i < MAX_N; ++i) { rep(j, i) { rep(k, i) { rep(l, i - j * j - k * k - j * k) { if (j * j + k * k + l * l + j * k + k * l + l * j == i) ++s[i]; } } } } int n; cin >> n; for (int i = 1; i <= n; ++i) cout << s[i] << endl; return 0; }
replace
16
17
16
17
TLE
p02608
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using namespace std; void solve() {} int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i * i <= n; i++) { for (int j = 1; j * j <= n; j++) { for (int k = 1; k * k <= n; k++) { int m = i * i + j * j + k * k + i * j + j * k + i * k; a[m]++; } } } rep(i, n) { cout << a[i + 1] << endl; } return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using namespace std; void solve() {} int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i * i <= n; i++) { for (int j = 1; j * j <= n; j++) { for (int k = 1; k * k <= n; k++) { int m = i * i + j * j + k * k + i * j + j * k + i * k; if (m <= n) { a[m]++; } } } } rep(i, n) { cout << a[i + 1] << endl; } return 0; }
replace
26
27
26
29
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll N; cin >> N; FOR(i, 1, N + 1) { ll cnt = 0; FOR(j, 1, 100) { FOR(k, 1, 100) { FOR(l, 1, 100) { if (j * j + k * k + l * l + j * k + k * l + l * j == i) { cnt++; } } } } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll N; cin >> N; FOR(i, 1, N + 1) { ll cnt = 0; FOR(j, 1, 100) { FOR(k, 1, 100) { FOR(l, 1, 100) { if (j * j + k * k + l * l + j * k + k * l + l * j == i) { cnt++; } else if (j * j + k * k + l * l + j * k + k * l + l * j > i) { break; } } } } cout << cnt << endl; } return 0; }
insert
18
18
18
20
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; vector<int> n(a); for (int x = 1; x <= a; x++) { for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { if (i * i + j * j + k * k + i * j + i * k + j * k == x) { n[x - 1]++; } } } } } for (int i = 0; i < a; i++) { cout << n[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; vector<int> n; n = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 1, 6, 0, 3, 0, 0, 0, 0, 0, 3, 3, 6, 0, 0, 3, 0, 0, 0, 0, 3, 3, 6, 0, 6, 0, 0, 0, 3, 0, 0, 1, 6, 0, 6, 6, 0, 0, 6, 0, 0, 0, 0, 3, 3, 3, 6, 0, 6, 3, 6, 0, 0, 0, 6, 0, 0, 0, 3, 3, 9, 0, 6, 3, 6, 0, 3, 6, 0, 0, 0, 0, 6, 1, 6, 0, 6, 6, 0, 3, 12, 0, 6, 0, 0, 3, 6, 0, 0, 0, 3, 3, 12, 0, 6, 3, 6, 0, 3, 6, 9, 0, 6, 0, 0, 0, 3, 6, 3, 3, 6, 0, 6, 3, 12, 0, 3, 6, 6, 0, 6, 0, 6, 3, 6, 0, 0, 1, 6, 3, 12, 6, 0, 0, 12, 0, 6, 0, 6, 6, 12, 0, 0, 6, 0, 0, 6, 0, 12, 3, 6, 0, 6, 3, 9, 6, 3, 6, 6, 0, 6, 0, 6, 0, 15, 6, 0, 0, 6, 0, 3, 3, 12, 0, 12, 6, 6, 0, 3, 6, 6, 3, 12, 0, 6, 0, 9, 6, 0, 0, 6, 3, 12, 1, 6, 6, 6, 6, 0, 0, 18, 0, 12, 0, 3, 6, 12, 0, 0, 6, 3, 6, 12, 0, 12, 0, 0, 0, 9, 3, 9, 6, 12, 3, 12, 0, 3, 6, 6, 0, 12, 0, 12, 0, 9, 9, 0, 0, 6, 3, 6, 3, 12, 6, 9, 3, 6, 0, 12, 3, 6, 3, 9, 6, 12, 6, 6, 0, 6, 0, 9, 6, 6, 0, 12, 3, 6, 0, 9, 6, 6, 1, 6, 0, 21, 12, 6, 0, 12, 0, 12, 0, 0, 6, 15, 6, 0, 6, 12, 0, 12, 0, 12, 0, 0, 0, 12, 0, 12, 12, 3, 3, 18, 3, 6, 3, 6, 6, 9, 9, 18, 0, 6, 0, 12, 0, 9, 6, 0, 3, 12, 3, 6, 6, 12, 6, 6, 0, 0, 0, 15, 3, 18, 3, 18, 3, 12, 6, 3, 6, 9, 0, 12, 0, 12, 0, 18, 12, 0, 0, 12, 3, 6, 0, 6, 6, 9, 6, 0, 0, 18, 1, 18, 3, 12, 6, 6, 6, 12, 0, 15, 6, 12, 6, 18, 0, 0, 6, 0, 9, 12, 0, 18, 0, 6, 3, 12, 0, 12, 12, 0, 0, 12, 0, 3, 6, 12, 6, 18, 9, 18, 0, 9, 6, 18, 0, 6, 0, 6, 3, 27, 6, 6, 6, 6, 3, 6, 0, 12, 6, 9, 0, 6, 0, 18, 0, 9, 9, 15, 3, 12, 6, 6, 3, 9, 6, 12, 12, 18, 0, 18, 0, 6, 6, 21, 6, 0, 0, 6, 3, 15, 6, 12, 6, 18, 0, 0, 0, 12, 6, 6, 3, 6, 4, 18, 6, 12, 6, 3, 9, 30, 0, 18, 0, 6, 6, 12, 6, 6, 9, 12, 0, 18, 6, 18, 0, 6, 0, 12, 0, 6, 12, 6, 3, 18, 0, 6, 6, 6, 6, 15, 3, 24, 0, 6, 3, 18, 0, 12, 6, 12, 6, 24, 0, 15, 18, 9, 6, 0, 0, 18, 3, 6, 0, 15, 12, 12, 6, 6, 0, 18, 0, 6, 3, 12, 0, 12, 6, 6, 9, 9, 6, 24, 3, 24, 0, 9, 12, 6, 6, 12, 0, 12, 0, 21, 9, 15, 6, 12, 3, 18, 3, 12, 6, 12, 6, 0, 0, 12, 0, 12, 6, 24, 0, 6, 12, 6, 1, 9, 6, 12, 6, 24, 0, 18, 3, 12, 6, 6, 12, 24, 0, 12, 6, 15, 6, 18, 0, 18, 0, 0, 0, 18, 9, 21, 12, 0, 6, 18, 0, 9, 6, 6, 6, 12, 0, 12, 0, 9, 9, 27, 6, 6, 3, 18, 6, 21, 6, 6, 12, 12, 0, 12, 0, 24, 12, 0, 0, 24, 3, 24, 6, 12, 12, 18, 0, 0, 0, 12, 0, 18, 3, 15, 6, 12, 9, 6, 0, 15, 6, 9, 12, 24, 0, 12, 3, 6, 6, 21, 6, 18, 3, 18, 0, 21, 12, 15, 6, 6, 0, 12, 3, 12, 9, 18, 9, 12, 6, 6, 6, 24, 0, 18, 3, 24, 0, 6, 6, 0, 6, 9, 6, 6, 4, 30, 0, 18, 12, 9, 6, 24, 0, 18, 0, 9, 12, 21, 6, 6, 12, 12, 0, 18, 0, 21, 15, 12, 0, 12, 6, 12, 12, 18, 0, 18, 0, 6, 0, 9, 12, 18, 6, 30, 0, 0, 0, 24, 6, 9, 3, 12, 6, 30, 3, 6, 12, 6, 12, 12, 0, 36, 0, 6, 3, 27, 12, 12, 6, 6, 6, 24, 0, 12, 6, 12, 0, 18, 0, 18, 15, 18, 3, 18, 6, 12, 6, 6, 12, 3, 6, 6, 0, 12, 3, 39, 3, 12, 12, 12, 3, 18, 0, 21, 12, 21, 6, 18, 0, 12, 0, 9, 9, 12, 9, 24, 9, 12, 6, 12, 6, 33, 0, 6, 0, 18, 0, 9, 15, 12, 6, 24, 6, 6, 3, 15, 6, 15, 12, 18, 0, 18, 1, 18, 6, 12, 6, 6, 0, 24, 6, 24, 12, 18, 6, 24, 0, 6, 6, 12, 15, 24, 0, 24, 6, 6, 0, 18, 0, 15, 18, 12, 0, 24, 0, 12, 6, 12, 12, 18, 6, 24, 0, 0, 6, 24, 3, 12, 0, 12, 6, 30, 9, 6, 12, 24, 12, 12, 0, 15, 18, 12, 0, 18, 0, 24, 6, 15, 6, 18, 3, 18, 3, 12, 6, 24, 12, 12, 12, 6, 0, 36, 0, 18, 3, 6, 12, 6, 9, 12, 0, 3, 12, 36, 0, 30, 0, 12, 0, 18, 6, 12, 9, 12, 6, 24, 3, 18, 12, 15, 9, 24, 0, 18, 6, 18, 9, 18, 12, 6, 6, 24, 3, 24, 0, 12, 12, 12, 0, 6, 0, 27, 12, 18, 3, 30, 3, 18, 6, 0, 12, 15, 6, 18, 0, 24, 0, 9, 6, 9, 12, 18, 7, 24, 0, 24, 12, 15, 12, 24, 0, 24, 0, 6, 9, 30, 9, 6, 6, 0, 9, 33, 12, 36, 0, 12, 0, 18, 0, 6, 21, 12, 6, 36, 6, 0, 3, 18, 6, 12, 6, 24, 0, 12, 3, 24, 6, 9, 12, 6, 6, 30, 6, 18, 12, 9, 9, 12, 0, 30, 3, 18, 3, 27, 6, 30, 12, 12, 0, 24, 0, 27, 12, 6, 0, 24, 3, 18, 18, 9, 6, 18, 0, 12, 3, 33, 18, 12, 9, 6, 0, 12, 6, 30, 0, 24, 12, 12, 0, 30, 6, 6, 6, 0, 6, 24, 0, 12, 0, 18, 15, 33, 6, 30, 15, 18, 0, 9, 12, 24, 9, 12, 0, 18, 6, 27, 18, 15, 6, 18, 3, 24, 0, 6, 6, 36, 12, 18, 0, 12, 3, 30, 3, 12, 6, 12, 15, 6, 0, 18, 12, 15, 9, 30, 0, 18, 6, 12, 12, 18, 6, 6, 3, 24, 1, 27, 12, 18, 6, 18, 0, 24, 0, 18, 15, 15, 21, 30, 6, 12, 12, 18, 0, 30, 6, 24, 0, 6, 0, 18, 6, 36, 12, 6, 6, 36, 0, 6, 12, 12, 12, 24, 0, 30, 0, 9, 6, 18, 0, 18, 12, 12, 6, 24, 6, 9, 15, 12, 0, 12, 6, 30, 9, 18, 0, 42, 3, 18, 6, 12, 18, 33, 12, 12, 0, 18, 0, 21, 12, 12, 12, 24, 6, 30, 0, 27, 18, 6, 12, 6, 0, 24, 0, 18, 15, 30, 0, 18, 12, 6, 0, 21, 6, 21, 12, 24, 0, 30, 0, 6, 6, 6, 12, 24, 0, 30, 12, 9, 12, 21, 3, 24, 0, 12, 3, 21, 18, 9, 18, 18, 6, 30, 3, 42, 6, 21, 6, 30, 0, 6, 3, 24, 9, 36, 6, 6, 9, 12, 6, 18, 12, 33, 9, 12, 0, 24, 9, 9, 6, 3, 18, 36, 6, 18, 0, 24, 6, 6, 6, 18, 0, 12, 0, 30, 3, 39, 12, 12, 7, 18, 0, 15, 18, 18, 9, 36, 0, 24, 6, 6, 18, 30, 0, 18, 9, 18, 3, 24, 6, 21, 12, 24, 0, 30, 3, 33, 24, 12, 6, 18, 6, 6, 6, 18, 6, 18, 12, 18, 0, 24, 6, 36, 3, 18, 6, 0, 12, 30, 0, 9, 24, 18, 0, 24, 0, 18, 0, 0, 12, 30, 15, 30, 6, 18, 3, 30, 0, 24, 18, 12, 0, 36, 3, 24, 12, 15, 18, 18, 6, 24, 3, 24, 12, 18, 12, 24, 0, 0, 6, 39, 6, 24, 3, 18, 3, 42, 6, 12, 12, 15, 9, 30, 0, 12, 0, 18, 6, 18, 12, 24, 15, 12, 0, 12, 12, 30, 12, 12, 0, 18, 0, 15, 15, 18, 18, 30, 3, 24, 12, 9, 6, 48, 0, 18, 0, 30, 0, 21, 6, 12, 12, 24, 12, 18, 3, 48, 24, 6, 6, 18, 0, 36, 0, 12, 15, 27, 6, 12, 12, 18, 6, 27, 6, 12, 9, 18, 0, 24, 6, 18, 18, 21, 0, 36, 0, 12, 0, 18, 12, 21, 18, 24, 0, 12, 1, 18, 9, 21, 18, 6, 9, 42, 3, 36, 12, 12, 12, 30, 0, 12, 6, 21, 12, 36, 6, 24, 9, 12, 6, 12, 12, 24, 12, 18, 0, 42, 0, 15, 6, 15, 15, 42, 6, 30, 6, 12, 12, 18, 12, 18, 0, 6, 6, 36, 0, 30, 18, 6, 0, 6, 0, 30, 18, 18, 0, 42, 0, 18, 6, 15, 18, 24, 0, 12, 6, 36, 9, 33, 12, 12, 12, 18, 0, 36, 0, 21, 21, 15, 18, 18, 15, 18, 0, 18, 6, 42, 6, 24, 0, 18, 3, 42, 6, 18, 12, 12, 12, 18, 0, 15, 12, 18, 12, 36, 0, 30, 12, 3, 21, 18, 0, 30, 6, 24, 0, 27, 12, 18, 12, 6, 0, 12, 0, 36, 15, 15, 3, 36, 12, 18, 6, 30, 6, 33, 12, 12, 0, 12, 6, 24, 6, 54, 18, 12, 3, 36, 9, 9, 12, 12, 18, 36, 0, 6, 0, 21, 15, 27, 9, 24, 12, 30, 6, 24, 6, 27, 18, 12, 0, 30, 0, 21, 12, 18, 6, 30, 0, 18, 0, 21, 18, 21, 6, 30, 0, 24, 3, 6, 6, 15, 27, 12, 10, 42, 6, 36, 12, 12, 6, 24, 0, 24, 6, 12, 12, 48, 6, 18, 12, 0, 3, 51, 6, 30, 6, 24, 0, 24, 0, 30, 21, 15, 12, 24, 9, 18, 6, 18, 12, 30, 9, 24, 0, 18, 0, 27, 18, 9, 6, 18, 9, 54, 0, 18, 24, 21, 18, 12, 0, 24, 0, 12, 0, 30, 9, 30, 12, 6, 9, 24, 6, 15, 15, 18, 0, 30, 3, 33, 18, 21, 12, 42, 3, 30, 6, 6, 24, 27, 6, 12, 0, 24, 3, 42, 6, 42, 9, 12, 6, 18, 6, 24, 12, 12, 12, 54, 0, 6, 12, 18, 6, 18, 18, 30, 12, 30, 0, 18, 0, 27, 18, 24, 0, 18, 0, 15, 24, 21, 6, 24, 3, 36, 6, 6, 6, 45, 21, 18, 0, 18, 6, 33, 3, 18, 0, 24, 15, 30, 0, 30, 24, 12, 6, 36, 0, 24, 3, 21, 24, 18, 15, 30, 3, 12, 6, 42, 12, 12, 12, 6, 0, 54, 6, 30, 15, 24, 18, 24, 6, 12, 0, 9, 6, 30, 0, 48, 0, 24, 0, 15, 12, 39, 12, 24, 6, 24, 6, 15, 30, 12, 6, 24, 0, 24, 3, 24, 12, 24, 6, 6, 18, 12, 4, 54, 6, 21, 18, 18, 0, 36, 6, 24, 9, 30, 12, 24, 9, 36, 6, 12, 18, 42, 3, 30, 0, 6, 9, 21, 6, 12, 30, 30, 6, 30, 0, 27, 12, 9, 18, 30, 0, 36, 0, 18, 9, 42, 6, 24, 12, 0, 6, 51, 12, 24, 12, 12, 0, 18, 6, 12, 18, 6, 6, 36, 3, 54, 9, 18, 6, 27, 12, 18, 0, 30, 0, 39, 9, 18, 18, 12, 9, 30, 6, 21, 12, 27, 18, 24, 0, 12, 0, 42, 18, 42, 6, 24, 15, 18, 0, 24, 12, 45, 12, 6, 0, 54, 0, 15, 21, 6, 6, 30, 6, 18, 12, 24, 18, 30, 6, 36, 0, 12, 3, 24, 12, 18, 18, 18, 12, 24, 0, 33, 12, 27, 6, 42, 0, 18, 6, 9, 15, 30, 6, 30, 6, 12, 6, 18, 6, 33, 15, 30, 0, 36, 3, 27, 21, 33, 24, 30, 9, 24, 0, 12, 18, 33, 6, 6, 0, 18, 3, 57, 12, 24, 18, 30, 9, 18, 0, 18, 12, 27, 12, 36, 0, 36, 6, 12, 6, 27, 12, 30, 9, 24, 6, 39, 18, 12, 24, 12, 0, 30, 0, 30, 6, 15, 15, 18, 3, 24, 18, 9, 12, 30, 9, 30, 0, 18, 6, 42, 18, 30, 0, 6, 10, 48, 0, 24, 12, 12, 18, 48, 0, 30, 3, 30, 15, 18, 6, 24, 18, 18, 0, 42, 6, 36, 15, 24, 0, 42, 12, 21, 24, 12, 12, 24, 0, 12, 6, 18, 18, 60, 6, 30, 0, 12, 0, 24, 0, 12, 18, 30, 15, 42, 0, 33, 30, 6, 6, 12, 0, 42, 3, 27, 6, 33, 12, 36, 12, 18, 0, 30, 6, 18, 12, 12, 0, 18, 6, 15, 27, 27, 6, 42, 6, 36, 9, 18, 30, 33, 9, 30, 0, 6, 6, 54, 6, 36, 24, 24, 0, 30, 3, 12, 6, 21, 24, 30, 0, 24, 0, 24, 12, 42, 9, 42, 21, 12, 12, 27, 12, 27, 6, 12, 0, 48, 6, 12, 18, 12, 12, 36, 6, 30, 0, 24, 0, 42, 12, 12, 0, 36, 0, 24, 15, 21, 21, 18, 6, 12, 9, 36, 18, 18, 15, 42, 0, 18, 6, 9, 18, 48, 12, 30, 9, 24, 3, 33, 6, 18, 18, 18, 0, 36, 3, 54, 24, 3, 12, 36, 9, 36, 6, 30, 12, 36, 12, 24, 0, 18, 6, 24, 6, 42, 0, 24, 18, 18, 0, 9, 30, 39, 12, 42, 0, 36, 0, 12, 12, 21, 12, 18, 12, 24, 6, 45, 6, 18, 24, 18, 0, 36, 0, 42, 15, 18, 6, 24, 6, 12, 12, 18, 12, 30, 6, 18, 0, 30, 1, 30, 9, 57, 9, 12, 9, 48, 6, 21, 24, 18, 12, 66, 0, 18, 6, 9, 24, 24, 24, 30, 12, 18, 0, 48, 6, 24, 18, 18, 0, 24, 3, 27, 18, 24, 12, 36, 6, 48, 6, 15, 18, 42, 6, 24, 0, 12, 12, 36, 6, 6, 24, 12, 3, 48, 0, 48, 18, 0, 12, 18, 0, 36, 6, 18, 9, 54, 15, 12, 12, 6, 6, 39, 6, 24, 18, 42, 0, 30, 0, 33, 18, 24, 18, 18, 9, 18, 0, 15, 18, 54, 0, 36, 0, 24, 0, 48, 24, 15, 18, 18, 12, 42, 9, 24, 12, 36, 21, 30, 0, 36, 12, 24, 3, 30, 0, 48, 15, 12, 6, 15, 18, 18, 18, 24, 0, 30, 0, 24, 24, 18, 9, 72, 0, 30, 6, 21, 18, 30, 6, 24, 0, 0, 6, 24, 18, 42, 12, 6, 15, 36, 0, 30, 18, 30, 12, 24, 0, 6, 0, 18, 12, 54, 9, 36, 9, 36, 9, 30, 6, 27, 27, 24, 0, 54, 6, 21, 18, 21, 6, 36, 15, 36, 3, 30, 12, 6, 18, 30, 0, 18, 6, 54, 0, 30, 21, 36, 9, 30, 6, 30, 24, 24, 6, 30, 0, 36, 12, 9, 24, 24, 12, 18, 9, 30, 0, 48, 12, 24, 12, 12, 0, 48, 0, 18, 12, 24, 24, 30, 6, 18, 12, 21, 12, 24, 0, 66, 0, 12, 0, 30, 9, 24, 24, 18, 13, 42, 3, 18, 18, 27, 24, 24, 0, 30, 6, 15, 18, 39, 12, 12, 9, 36, 12, 54, 12, 42, 18, 6, 0, 36, 0, 51, 18, 12, 0, 66, 12, 24, 0, 6, 24, 51, 12, 24, 0, 24, 0, 33, 6, 18, 18, 30, 6, 42, 3, 18, 30, 15, 15, 30, 0, 30, 6, 30, 12, 48, 12, 24, 12, 12, 9, 36, 6, 36, 6, 12, 0, 30, 0, 24, 21, 24, 15, 42, 12, 24, 6, 9, 18, 15, 9, 42, 0, 24, 12, 66, 12, 30, 24, 6, 9, 54, 0, 36, 12, 21, 12, 36, 0, 24, 3, 24, 15, 36, 6, 30, 24, 12, 6, 33, 6, 39, 21, 30, 0, 42, 6, 12, 30, 30, 18, 36, 0, 48, 3, 36, 12, 30, 18, 18, 0, 24, 0, 30, 6, 33, 21, 24, 6, 18, 12, 24, 12, 12, 15, 48, 0, 24, 6, 21, 21, 60, 6, 24, 12, 18, 0, 30, 12, 15, 12, 24, 0, 24, 3, 60, 27, 18, 12, 30, 3, 24, 9, 21, 12, 60, 18, 24, 0, 24, 9, 33, 6, 36, 12, 24, 15, 42, 6, 27, 36, 27, 6, 42, 0, 42, 6, 12, 15, 15, 24, 42, 18, 12, 0, 33, 6, 21, 18, 24, 0, 48, 3, 36, 9, 24, 24, 30, 6, 36, 0, 39, 18, 60, 6, 18, 0, 12, 6, 21, 27, 30, 0, 18, 6, 42, 6, 42, 18, 24, 9, 48, 0, 6, 6, 18, 18, 18, 6, 18, 15, 30, 4, 60, 12, 30, 30, 18, 0, 36, 0, 27, 18, 30, 18, 48, 9, 30, 12, 18, 6, 42, 9, 48, 0, 18, 6, 42, 6, 30, 24, 12, 3, 36, 0, 36, 36, 15, 18, 30, 0, 66, 0, 12, 18, 42, 9, 24, 15, 18, 12, 54, 6, 18, 21, 36, 0, 30, 6, 24, 24, 12, 6, 24, 9, 36, 12, 6, 12, 45, 12, 36, 0, 36, 0, 48, 3, 24, 18, 12, 24, 36, 0, 30, 12, 30, 21, 30, 0, 6, 15, 18, 15, 66, 12, 42, 3, 12, 0, 39, 12, 30, 12, 18, 0, 54, 6, 30, 24, 9, 12, 60, 12, 30, 12, 30, 24, 24, 18, 30, 0, 36, 0, 27, 9, 45, 18, 24, 12, 24, 0, 36, 24, 12, 6, 60, 0, 18, 0, 24, 15, 51, 9, 24, 12, 30, 12, 27, 18, 51, 18, 24, 0, 36, 6, 27, 27, 12, 30, 36, 6, 30, 0, 12, 6, 42, 0, 18, 0, 18, 0, 48, 12, 45, 24, 6, 15, 42, 6, 12, 18, 27, 9, 54, 0, 42, 3, 33, 12, 15, 12, 54, 18, 30, 6, 36, 18, 21, 30, 18, 0, 48, 3, 30, 18, 36, 6, 18, 0, 18, 12, 57, 24, 42, 6, 24, 0, 18, 12, 36, 18, 30, 12, 36, 3, 78, 0, 24, 6, 6, 36, 42, 0, 24, 0, 21, 15, 33, 6, 42, 18, 12, 3, 30, 12, 30, 27, 24, 0, 42, 12, 39, 12, 30, 12, 30, 15, 30, 6, 12, 24, 54, 6, 24, 0, 18, 6, 33, 12, 18, 24, 24, 7, 30, 0, 60, 24, 21, 12, 30, 0, 48, 6, 18, 15, 39, 12, 18, 18, 18, 0, 48, 12, 54, 18, 42, 0, 30, 0, 15, 30, 27, 18, 72, 0, 30, 15, 12, 12, 30, 18, 36, 0, 6, 3, 60, 15, 24, 18, 6, 18, 54, 6, 21, 24, 24, 12, 30, 0, 30, 6, 30, 15, 54, 6, 48, 12, 30, 12, 36, 0, 24, 3, 24, 0, 54, 6, 18, 30, 15, 6, 42, 9, 36, 0, 21, 30, 15, 12, 12, 0, 24, 3, 72, 0, 51, 39, 24, 12, 30, 3, 33, 18, 15, 12, 42, 0, 30, 12, 27, 24, 51, 12, 42, 12, 18, 3, 42, 12, 39, 18, 12, 0, 30, 0, 24, 21, 21, 21, 30, 6, 66, 12, 12, 6, 69, 21, 30, 0, 24, 6, 45, 12, 12, 18, 42, 12, 18, 0, 39, 30, 33, 12, 54, 0, 12, 0, 12, 18, 36, 9, 30, 9, 24, 9, 60, 12, 30, 12, 12, 0, 42, 9, 42, 18, 45, 24, 42, 6, 12, 9, 24, 6, 30, 12, 42, 0, 30, 6, 15, 15, 30, 12, 18, 12, 54, 6, 21, 30, 12, 33, 60, 0, 48, 0, 30, 15, 42, 6, 24, 24, 30, 0, 36, 18, 33, 18, 12, 0, 60, 0, 72, 15, 12, 9, 30, 12, 24, 15, 21, 24, 51, 12, 24, 0, 24, 6, 12, 6, 33, 24, 36, 9, 54, 6, 27, 24, 30, 6, 48, 0, 24, 3, 36, 27, 42, 15, 18, 18, 12, 6, 54, 6, 30, 15, 36, 0, 12, 12, 18, 24, 21, 18, 30, 3, 60, 0, 33, 12, 36, 18, 48, 0, 24, 1, 39, 12, 24, 18, 24, 9, 66, 6, 48, 24, 12, 12, 42, 0, 24, 6, 18, 12, 63, 6, 36, 24, 18, 0, 39, 12, 39, 24, 24, 0, 54, 6, 15, 24, 15, 24, 48, 3, 36, 12, 12, 24, 39, 18, 36, 0, 42, 6, 42, 6, 60, 24, 12, 18, 18, 0, 45, 6, 6, 6, 72, 0, 30, 6, 24, 9, 36, 12, 24, 9, 30, 15, 36, 18, 33, 24, 6, 0, 54, 0, 33, 36, 18, 24, 36, 6, 18, 6, 24, 18, 75, 6, 18, 0, 18, 0, 48, 9, 36, 18, 42, 9, 30, 0, 27, 36, 24, 15, 42, 0, 42, 18, 36, 12, 18, 12, 72, 9, 24, 0, 54, 18, 21, 24, 12, 0, 60, 0, 24, 24, 39, 12, 42, 18, 30, 6, 9, 12, 48, 12, 30, 0, 18, 12, 36, 15, 48, 18, 18, 3, 42, 6, 42, 18, 18, 24, 54, 0, 36, 0, 24, 36, 42, 0, 12, 27, 30, 6, 60, 6, 30, 24, 12, 0, 36, 3, 42, 12, 18, 12, 36, 9, 30, 0, 15, 18, 33, 12, 54, 0, 30, 6, 33, 21, 27, 30, 42, 12, 54, 9, 42, 24, 27, 6, 36, 0, 24, 12, 24, 12, 45, 24, 12, 6, 30, 12, 69, 12, 42, 12, 30, 0, 24, 0, 42, 18, 24, 15, 60, 9, 48, 18, 18, 24, 27, 12, 36, 0, 30, 0, 54, 9, 30, 18, 24, 15, 48, 0, 24, 24, 45, 24, 24, 0, 18, 6, 36, 9, 54, 15, 24, 12, 12, 6, 18, 12, 54, 18, 12, 0, 60, 3, 48, 30, 12, 18, 60, 6, 24, 3, 36, 12, 33, 12, 36, 0, 36, 6, 36, 3, 33, 24, 12, 13, 42, 12, 27, 18, 30, 12, 54, 0, 30, 12, 21, 39, 54, 6, 54, 18, 18, 0, 33, 12, 36, 36, 36, 0, 30, 0, 42, 33, 18, 18, 36, 12, 30, 3, 30, 12, 66, 6, 30, 0, 18, 12, 63, 18, 24, 6, 30, 12, 48, 9, 6, 24, 30, 12, 42, 0, 72, 0, 30, 12, 48, 3, 24, 15, 12, 12, 66, 18, 9, 36, 12, 0, 54, 0, 54, 18, 15, 30, 36, 6, 12, 0, 21, 18, 54, 12, 30, 0, 6, 0, 36, 15, 60, 18, 18, 15, 48, 6, 27, 24, 21, 12, 54, 0, 54, 9, 12, 24, 48, 12, 48, 15, 54, 6, 36, 6, 39, 24, 24, 0, 24, 3, 33, 24, 18, 18, 66, 12, 18, 12, 30, 12, 75, 15, 36, 0, 30, 9, 24, 6, 21, 24, 24, 12, 60, 0, 66, 36, 12, 18, 36, 0, 24, 6, 30, 18, 39, 18, 30, 12, 24, 9, 30, 6, 36, 18, 18, 0, 54, 12, 33, 24, 36, 6, 66, 0, 30, 6, 12, 12, 33, 24, 54, 0, 18, 3, 60, 3, 30, 24, 24, 21, 48, 0, 18, 30, 51, 12, 18, 0, 30, 12, 33, 15, 18, 12, 30, 27, 24, 0, 48, 12, 45, 6, 30, 0, 72, 0, 51, 18, 27, 27, 54, 9, 48, 12, 27, 30, 36, 18, 18, 0, 42, 3, 36, 9, 45, 30, 6, 6, 36, 3, 51, 24, 24, 18, 72, 0, 18, 6, 9, 36, 42, 0, 36, 9, 30, 12, 60, 30, 24, 15, 24, 0, 36, 6, 30, 27, 27, 18, 42, 12, 48, 0, 42, 0, 33, 24, 24, 0, 30, 0, 42, 12, 48, 9, 36, 9, 24, 6, 27, 36, 12, 9, 60, 0, 30, 12, 15, 18, 42, 18, 36, 18, 24, 7, 48, 12, 54, 24, 30, 0, 78, 0, 18, 18, 27, 24, 24, 6, 30, 12, 33, 18, 60, 15, 54, 0, 12, 12, 36, 12, 36, 24, 30, 18, 54, 0, 18, 18, 18, 24, 84, 0, 54, 0, 27, 15, 42, 6, 36, 12, 18, 9, 54, 6, 30, 30, 24, 0, 30, 9, 60, 30, 36, 6, 42, 12, 30, 6, 6, 30, 60, 0, 18, 0, 24, 9, 51, 18, 24, 33, 30, 0, 42, 12, 60, 18, 18, 36, 18, 0, 24, 0, 18, 9, 78, 12, 48, 24, 12, 0, 48, 6, 12, 18, 42, 0, 48, 0, 30, 27, 18, 6, 48, 3, 66, 21, 18, 18, 33, 12, 48, 0, 30, 6, 63, 21, 18, 36, 24, 15, 60, 6, 36, 30, 36, 0, 48, 0, 48, 3, 36, 30, 42, 18, 24, 24, 12, 6, 21, 6, 72, 12, 36, 0, 60, 6, 12, 18, 15, 24, 60, 9, 30, 0, 39, 30, 54, 12, 18, 0, 18, 3, 60, 9, 57, 24, 6, 18, 48, 6, 60, 18, 18, 9, 48, 0, 24, 12, 18, 18, 39, 6, 42, 15, 36, 6, 36, 18, 18, 30, 18, 0, 42, 6, 39, 27, 27, 18, 48, 12, 42, 12, 24, 18, 27, 9, 30, 0, 24, 9, 81, 12, 72, 12, 30, 6, 36, 0, 33, 42, 39, 30, 42, 0, 12, 3, 12, 6, 24, 18, 48, 12, 48, 3, 63, 24, 24, 27, 30, 0, 78, 6, 36, 18, 36, 30, 30, 12, 36, 12, 30, 6, 60, 12, 48, 0, 24, 0, 36, 21, 30, 24, 30, 12, 48, 0, 36, 12, 24, 27, 36, 0, 42, 12, 27, 24, 54, 6, 18, 12, 48, 0, 30, 6, 72, 24, 12, 0, 30, 3, 45, 24, 0, 18, 78, 15, 18, 18, 39, 18, 39, 9, 36, 0, 24, 6, 39, 12, 30, 18, 30, 16, 48, 0, 36, 30, 12, 12, 60, 0, 42, 3, 24, 21, 84, 33, 30, 12, 18, 18, 48, 12, 36, 12, 30, 0, 48, 9, 42, 36, 42, 6, 48, 3, 42, 0, 33, 24, 30, 12, 36, 0, 36, 6, 54, 12, 30, 30, 6, 21, 66, 0, 39, 24, 36, 24, 36, 0, 24, 12, 30, 15, 54, 12, 78, 30, 6, 0, 33, 12, 27, 30, 30, 0, 36, 6, 18, 36, 36, 6, 66, 3, 60, 6, 18, 30, 42, 0, 12, 0, 36, 6, 54, 6, 33, 24, 24, 12, 54, 0, 42, 12, 15, 12, 60, 0, 30, 0, 21, 18, 75, 18, 48, 18, 18, 15, 30, 24, 42, 33, 36, 0, 30, 6, 45, 24, 9, 30, 36, 3, 54, 15, 24, 18, 63, 18, 42, 0, 24, 0, 75, 6, 30, 9, 30, 15, 42, 12, 33, 36, 21, 24, 60, 0, 54, 9, 30, 30, 48, 12, 18, 12, 24, 0, 66, 12, 24, 18, 36, 0, 72, 6, 36, 15, 27, 27, 30, 6, 12, 18, 24, 6, 78, 15, 42, 0, 12, 6, 27, 24, 51, 18, 36, 12, 60, 3, 51, 30, 12, 24, 36, 0, 30, 0, 48, 12, 21, 6, 36, 24, 54, 6, 42, 6, 36, 36, 6, 0, 54, 12, 27, 15, 18, 18, 66, 6, 42, 0, 15, 30, 63, 12, 48, 0, 36, 3, 63, 12, 36, 30, 18, 9, 48, 3, 48, 36, 30, 12, 42, 0, 72, 6, 36, 30, 30, 12, 24, 12, 6, 15, 75, 18, 30, 6, 36, 0, 24, 0, 18, 36, 48, 18, 60, 18, 60, 12, 33, 12, 33, 15, 72, 0, 18, 9, 54, 15, 21, 30, 36, 12, 30, 0, 42, 24, 48, 18, 36, 0, 24, 6, 18, 15, 81, 12, 12, 27, 36, 12, 30, 6, 36, 18, 24, 0, 48, 6, 36, 36, 27, 6, 48, 9, 36, 3, 36, 36, 36, 24, 30, 0, 24, 1, 42, 6, 66, 27, 24, 18, 48, 12, 51, 18, 24, 18, 84, 0, 24, 6, 12, 9, 63, 18, 48, 9, 30, 0, 36, 12, 33, 24, 30, 0, 72, 0, 42, 48, 36, 18, 42, 12, 42, 15, 24, 12, 60, 15, 24, 0, 12, 21, 72, 3, 42, 30, 24, 18, 36, 6, 42, 18, 30, 12, 42, 0, 48, 12, 12, 24, 24, 18, 66, 6, 24, 0, 93, 12, 51, 30, 12, 0, 54, 6, 18, 27, 24, 24, 36, 12, 30, 0, 45, 18, 60, 6, 54, 0, 24, 0, 51, 24, 21, 18, 30, 6, 72, 6, 6, 18, 21, 36, 42, 0, 48, 12, 27, 24, 36, 6, 30, 27, 30, 6, 39, 18, 51, 36, 30, 0, 42, 0, 66, 18, 36, 6, 66, 9, 24, 12, 24, 24, 78, 12, 36, 0, 36, 12, 60, 15, 42, 24, 6, 15, 54, 0, 33, 30, 21, 30, 42, 0, 54, 0, 24, 9, 60, 9, 36, 24, 24, 6, 66, 12, 48, 18, 54, 0, 30, 0, 30, 39, 30, 18, 48, 6, 42, 12, 33, 24, 33, 12, 60, 0, 18, 6, 42, 24, 42, 24, 6, 12, 72, 6, 42, 30, 18, 9, 30, 0, 24, 15, 30, 18, 60, 12, 54, 15, 24, 0, 48, 24, 33, 12, 36, 0, 66, 6, 36, 18, 21, 30, 72, 3, 24, 9, 27, 30, 30, 18, 42, 0, 42, 0, 72, 6, 39, 42, 24, 18, 60, 3, 24, 18, 36, 18, 30, 0, 54, 6, 27, 33, 60, 12, 24, 24, 18, 18, 30, 12, 21, 33, 48, 0, 78, 12, 78, 12, 30, 12, 42, 12, 48, 0, 24, 12, 75, 18, 24, 0, 18, 0, 33, 24, 30, 21, 42, 15, 30, 12, 39, 30, 51, 12, 54, 0, 36, 12, 18, 12, 48, 24, 78, 18, 18, 6, 78, 6, 24, 30, 12, 0, 42, 0, 45, 18, 15, 27, 42, 0, 54, 18, 36, 18, 36, 6, 48, 0, 30, 12, 36, 21, 45, 6, 24, 7, 54, 0, 27, 42, 33, 24, 72, 0, 42, 0, 48, 24, 45, 18, 18, 15, 36, 15, 66, 6, 66, 30, 18, 0, 48, 0, 27, 39, 30, 18, 66, 27, 12, 12, 18, 24, 60, 6, 66, 0, 42, 0, 42, 6, 33, 21, 36, 12, 42, 6, 21, 36, 33, 21, 48, 0, 66, 12, 6, 18, 75, 24, 36, 12, 18, 0, 81, 12, 42, 30, 36, 0, 24, 0, 30, 30, 30, 6, 60, 9, 60, 6, 24, 30, 30, 6, 30, 0, 30, 12, 75, 18, 30, 24, 24, 15, 78, 0, 42, 24, 18, 30, 42, 0, 30, 12, 21, 12, 48, 9, 60, 21, 30, 12, 24, 24, 39, 21, 24, 0, 54, 3, 39, 30, 33, 24, 72, 12, 60, 0, 18, 24, 57, 12, 24, 0, 24, 3, 90, 9, 12, 21, 36, 12, 30, 18, 84, 24, 30, 9, 60, 0, 36, 18, 18, 24, 78, 18, 24, 18, 48, 6, 24, 0, 45, 30, 24, 0, 66, 3, 60, 36, 21, 42, 42, 6, 30, 6, 33, 12, 60, 21, 36, 0, 6, 6, 36, 15, 36, 30, 48, 21, 48, 0, 39, 36, 36, 6, 54, 0, 66, 3, 18, 18, 33, 24, 36, 18, 30, 9, 66, 6, 15, 36, 24, 0, 96, 6, 30, 12, 42, 6, 36, 6, 36, 9, 27, 36, 42, 12, 42, 0, 18, 6, 51, 12, 78, 18, 30, 9, 54, 12, 39, 24, 24, 33, 66, 0, 36, 9, 45, 33, 36, 12, 18, 27, 36, 0, 78, 12, 48, 24, 30, 0, 42, 9, 48, 21, 18, 9, 60, 12, 54, 6, 21, 24, 72, 3, 66, 0, 18, 18, 33, 12, 21, 36, 36, 6, 36, 6, 60, 36, 36, 18, 48, 0, 24, 0, 30, 24, 87, 24, 24, 27, 42, 6, 60, 18, 66, 6, 18, 0, 36, 6, 39, 36, 30, 18, 36, 9, 30, 0, 18, 18, 51, 12, 48, 0, 54, 0, 48, 18, 36, 30, 36, 30, 66, 3, 12, 18, 15, 39, 60, 0, 24, 12, 66, 6, 54, 12, 48, 6, 18, 7, 30, 24, 48, 18, 30, 0, 84, 0, 30, 48, 12, 15, 60, 9, 42, 18, 42, 18, 42, 18, 48, 0, 30, 9, 48, 21, 69, 36, 12, 12, 48, 0, 57, 18, 24, 24, 66, 0, 36, 6, 24, 21, 69, 6, 54, 12, 30, 18, 72, 18, 30, 30, 18, 0, 42, 0, 42, 42, 12, 18, 42, 6, 54, 9, 42, 12, 72, 18, 24, 0, 24, 3, 78, 0, 24, 24, 30, 15, 60, 6, 42, 30, 39, 21, 36, 0, 54, 12, 27, 24, 42, 24, 72, 21, 30, 0, 48, 18, 24, 30, 12, 0, 30, 3, 24, 15, 72, 33, 42, 6, 24, 24, 12, 24, 66, 12, 60, 0, 24, 6, 63, 12, 42, 18, 24, 18, 84, 6, 30, 24, 24, 6, 90, 0, 72, 6, 21, 24, 30, 18, 18, 30, 24, 6, 66, 18, 54, 18, 36, 0, 36, 12, 60, 27, 30, 18, 90, 18, 18, 0, 18, 24, 48, 24, 30, 0, 36, 6, 36, 18, 66, 36, 30, 3, 66, 3, 57, 48, 12, 18, 36, 0, 48, 6, 36, 21, 48, 0, 60, 12, 36, 12, 72, 0, 36, 30, 30, 0, 48, 0, 33, 30, 48, 9, 54, 9, 36, 24, 18, 30, 42, 18, 54, 0, 12, 0, 54, 12, 21, 24, 30, 21, 72, 0, 66, 24, 27, 18, 36, 0, 24, 0, 45, 24, 78, 0, 42, 21, 24, 12, 39, 30, 54, 30, 24, 0, 84, 15, 24, 24, 9, 30, 54, 9, 48, 6, 33, 18, 57, 18, 30, 0, 60, 3, 54, 27, 33, 30, 36, 24, 42, 0, 54, 18, 39, 24, 54, 0, 60, 18, 24, 15, 75, 12, 24, 12, 42, 0, 39, 12, 36, 36, 36, 0, 30, 3, 66, 42, 15, 24, 72, 12, 48, 12, 42, 12, 48, 15, 24, 0, 18, 18, 60, 6, 60, 18, 36, 9, 24, 6, 27, 36, 30, 24, 90, 0, 60, 3, 21, 18, 54, 24, 48, 18, 18, 12, 51, 24, 39, 18, 18, 0, 72, 12, 42, 21, 36, 24, 36, 6, 36, 0, 33, 18, 42, 0, 60, 0, 18, 6, 42, 21, 39, 39, 36, 13, 84, 6, 24, 18, 30, 24, 78, 0, 36, 3, 54, 39, 51, 18, 30, 21, 24, 3, 60, 12, 87, 42, 30, 0, 36, 6, 30, 15, 36, 12, 54, 18, 42, 12, 27, 24, 84, 15, 42, 0, 18, 9, 54, 18, 30, 30, 48, 12, 72, 0, 54, 42, 9, 12, 36, 0, 60, 0, 27, 21, 78, 18, 42, 30, 30, 6, 54, 6, 30, 18, 24, 0, 60, 12, 42, 36, 48, 24, 54, 6, 36, 15, 12, 48, 21, 12, 30, 0, 36, 0, 102, 6, 18, 12, 24, 9, 60, 12, 48, 24, 33, 30, 66, 0, 30, 12, 30, 15, 60, 12, 54, 36, 30, 0, 36, 6, 72, 18, 36, 0, 54, 0, 30, 36, 9, 15, 60, 0, 60, 15, 39, 12, 63, 18, 42, 0, 30, 18, 60, 21, 57, 30, 0, 18, 54, 3, 75, 30, 48, 24, 42, 0, 24, 12, 36, 42, 57, 9, 48, 9, 36, 6, 45, 12, 24, 48, 54, 0, 66, 0, 45, 33, 30, 18, 54, 18, 36, 0, 36, 6, 54, 30, 54, 0, 36, 0, 66, 12, 42, 21, 24, 18, 48, 6, 21, 48, 42, 12, 60, 0, 84, 12, 0, 12, 54, 24, 36, 18, 18, 12, 81, 18, 33, 18, 12, 0, 66, 3, 66, 6, 33, 48, 48, 6, 24, 24, 36, 18, 60, 6, 36, 0, 24, 6, 39, 21, 42, 18, 42, 12, 60, 0, 24, 30, 33, 36, 72, 0, 30, 0, 36, 36, 42, 12, 36, 15, 24, 15, 75, 30, 63, 27, 24, 0, 42, 6, 63, 30, 18, 12, 108, 9, 48, 12, 24, 12, 72, 18, 30, 0, 54, 6, 30, 9, 63, 27, 48, 15, 36, 6, 48, 36, 18, 12, 54, 0, 42, 9, 36, 36, 63, 18, 36, 24, 36, 0, 75, 6, 63, 24, 36, 0, 48, 6, 27, 39, 30, 18, 30, 9, 54, 18, 36, 18, 39, 21, 66, 0, 30, 0, 54, 18, 42, 36, 12, 24, 108, 0, 30, 24, 42, 12, 48, 0, 24, 0, 15, 9, 48, 18, 66, 24, 24, 12, 54, 12, 36, 21, 54, 0, 54, 18, 45, 42, 36, 24, 42, 3, 36, 0, 42, 48, 42, 12, 36, 0, 36, 1, 60, 18, 36, 18, 36, 15, 54, 9, 60, 30, 24, 21, 48, 0, 24, 18, 24, 18, 90, 6, 72, 15, 36, 9, 48, 6, 36, 42, 48, 0, 78, 3, 54, 27, 18, 36, 48, 15, 54, 12, 30, 24, 84, 12, 18, 0, 18, 12, 105, 12, 24, 30, 30, 18, 36, 0, 60, 30, 27, 12, 48, 0, 90, 6, 18, 18, 33, 21, 42, 24, 24, 12, 45, 24, 60, 36, 36, 0, 66, 6, 27, 15, 42, 24, 60, 12, 18, 9, 30, 18, 84, 12, 72, 0, 12, 6, 42, 21, 45, 12, 18, 9, 96, 12, 21, 30, 30, 24, 66, 0, 48, 12, 42, 18, 36, 18, 24, 24, 24, 0, 30, 12, 27, 42, 18, 0, 72, 0, 84, 27, 54, 15, 102, 12, 36, 6, 39, 36, 36, 15, 36, 0, 30, 15, 57, 12, 57, 42, 30, 9, 60, 6, 27, 42, 27, 30, 36, 0, 54, 6, 24, 21, 78, 12, 42, 18, 18, 12, 84, 18, 54, 18, 48, 0, 66, 12, 15, 36, 30, 18, 72, 9, 66, 0, 27, 18, 24, 6, 78, 0, 42, 6, 81, 27, 27, 36, 24, 24, 48, 0, 72, 18, 39, 30, 42, 0, 18, 18, 30, 24, 78, 6, 18, 18, 36, 0, 48, 30, 84, 6, 18, 0, 54, 0, 42, 36, 12, 30, 90, 12, 48, 18, 24, 18, 21, 18, 48, 0, 60, 0, 60, 6, 30, 42, 24, 18, 66, 0, 27, 36, 24, 18, 54, 0, 48, 6, 30, 18, 90, 15, 42, 9, 48, 18, 42, 6, 45, 24, 36, 0, 48, 0, 78, 39, 27, 12, 42, 27, 48, 6, 45, 18, 72, 36, 48, 0, 18, 9, 66, 9, 54, 33, 18, 18, 66, 12, 39, 36, 45, 12, 72, 0, 48, 12, 21, 39, 33, 18, 60, 18, 36, 0, 78, 18, 39, 36, 24, 0, 30, 0, 30, 30, 54, 21, 66, 6, 30, 21, 39, 18, 60, 15, 72, 0, 30, 18, 45, 12, 39, 18, 60, 6, 66, 15, 36, 30, 12, 18, 60, 0, 60, 0, 18, 33, 57, 18, 24, 24, 42, 6, 66, 12, 81, 42, 18, 0, 36, 6, 42, 18, 24, 24, 72, 0, 18, 0, 30, 30, 87, 18, 36, 0, 42, 3, 45, 12, 36, 42, 24, 25, 30, 6, 72, 24, 18, 18, 60, 0, 102, 12, 42, 12, 90, 12, 24, 27, 24, 12, 69, 24, 30, 18, 42, 0, 48, 0, 42, 45, 39, 15, 60, 18, 30, 12, 33, 24, 72, 18, 36, 0, 24, 12, 51, 24, 39, 36, 24, 6, 120, 0, 72, 24, 30, 30, 30, 0, 24, 12, 72, 18, 54, 3, 84, 30, 30, 21, 42, 24, 30, 18, 30, 0, 54, 0, 36, 30, 24, 30, 72, 9, 72, 6, 30, 24, 36, 24, 30, 0, 30, 0, 90, 12, 48, 27, 24, 6, 54, 12, 39, 36, 18, 18, 78, 0, 36, 12, 18, 39, 66, 6, 54, 18, 36, 0, 54, 18, 42, 12, 30, 0, 78, 0, 48, 45, 27, 36, 36, 9, 54, 15, 6, 12, 99, 15, 48, 0, 24, 3, 60, 12, 45, 36, 36, 30, 24, 12, 57, 30, 42, 18, 54, 0, 36, 6, 45, 24, 63, 30, 60, 12, 42, 6, 102, 18, 30, 33, 18, 0, 84, 12, 54, 24, 39, 12, 42, 0, 36, 0, 54, 24, 60, 12, 42, 0, 48, 6, 30, 9, 93, 24, 18, 21, 60, 6, 21, 36, 18, 54, 102, 0, 30, 18, 36, 21, 48, 12, 30, 27, 42, 3, 54, 12, 66, 36, 36, 0, 48, 9, 45, 33, 30, 9, 84, 18, 30, 12, 33, 36, 51, 12, 54, 0, 36, 18, 42, 12, 30, 36, 24, 9, 72, 0, 48, 30, 36, 6, 78, 0, 42, 0, 18, 24, 63, 21, 36, 18, 24, 15, 66, 0, 42, 27, 54, 0, 30, 9, 51, 45, 45, 24, 48, 12, 72, 12, 33, 24, 39, 30, 66, 0, 18, 6, 69, 12, 36, 24, 36, 18, 90, 6, 60, 24, 36, 27, 36, 0, 60, 18, 33, 21, 84, 12, 36, 30, 18, 0, 33, 24, 51, 30, 24, 0, 84, 0, 57, 33, 36, 21, 84, 12, 30, 12, 33, 36, 63, 18, 24, 0, 30, 6, 90, 21, 66, 30, 30, 24, 36, 0, 54, 12, 51, 18, 78, 0, 36, 0, 18, 18, 54, 21, 48, 12, 66, 18, 21, 18, 33, 21, 42, 0, 66, 6, 48, 54, 21, 30, 66, 12, 66, 0, 24, 24, 63, 24, 36, 0, 42, 3, 60, 18, 30, 6, 36, 9, 54, 6, 72, 48, 36, 15, 54, 0, 30, 27, 12, 18, 60, 12, 66, 15, 48, 10, 84, 12, 39, 42, 12, 0, 66, 6, 24, 18, 21, 36, 54, 24, 24, 12, 51, 18, 66, 12, 90, 0, 18, 6, 87, 15, 75, 24, 30, 15, 60, 0, 24, 42, 24, 24, 48, 0, 84, 6, 51, 39, 60, 12, 18, 30, 36, 12, 60, 12, 60, 48, 36, 0, 54, 6, 42, 12, 6, 18, 78, 6, 48, 12, 12, 36, 84, 0, 48, 0, 54, 3, 48, 18, 45, 51, 54, 6, 72, 6, 51, 30, 45, 30, 48, 0, 36, 6, 36, 15, 78, 24, 42, 24, 24, 0, 90, 18, 36, 24, 24, 0, 36, 0, 36, 30, 30, 30, 66, 6, 78, 21, 30, 12, 21, 15, 60, 0, 36, 12, 66, 21, 36, 24, 30, 18, 60, 9, 54, 48, 24, 18, 48, 0, 30, 6, 42, 18, 81, 18, 54, 27, 24, 12, 30, 18, 84, 30, 24, 0, 102, 9, 42, 42, 36, 24, 90, 3, 30, 0, 60, 30, 42, 18, 24, 0, 18, 0, 78, 12, 42, 27, 42, 18, 66, 18, 45, 18, 42, 9, 84, 0, 54, 6, 15, 54, 63, 18, 54, 24, 24, 9, 57, 24, 45, 54, 36, 0, 60, 0, 66, 27, 33, 18, 30, 9, 60, 24, 30, 12, 54, 21, 24, 0, 12, 18, 108, 15, 66, 12, 30, 27, 66, 0, 36, 30, 36, 24, 66, 0, 60, 0, 9, 24, 54, 12, 90, 15, 42, 0, 51, 30, 18, 30, 48, 0, 84, 9, 48, 21, 54, 30, 24, 18, 36, 12, 45, 18, 96, 6, 30, 0, 30, 9, 30, 24, 42, 24, 24, 15, 66, 6, 69, 36, 15, 15, 84, 0, 36, 15, 48, 27, 45, 18, 42, 30, 36, 0, 66, 6, 72, 30, 48, 0, 42, 3, 51, 39, 30, 33, 78, 12, 24, 18, 30, 18, 105, 21, 72, 0, 42, 12, 39, 18, 27, 42, 24, 6, 66, 3, 60, 42, 30, 30, 60, 0, 54, 6, 54, 24, 57, 6, 54, 6, 24, 24, 54, 12, 57, 27, 42, 0, 48, 6, 36, 27, 57, 12, 84, 12, 60, 0, 12, 30, 54, 24, 48, 0, 18, 3, 105, 36, 48, 42, 24, 18, 48, 6, 30, 36, 45, 42, 42, 0, 54, 9, 36, 12, 48, 12, 54, 30, 30, 6, 48, 6, 51, 18, 36, 0, 102, 6, 18, 30, 33, 24, 48, 18, 60, 12, 60, 30, 45, 12, 36, 0, 54, 12, 60, 6, 48, 54, 12, 13, 60, 0, 72, 18, 24, 6, 90, 0, 48, 12, 15, 42, 96, 18, 36, 18, 36, 6, 78, 24, 48, 18, 30, 0, 48, 18, 78, 42, 24, 30, 60, 6, 60, 12, 18, 12, 42, 30, 42, 0, 24, 0, 81, 9, 54, 18, 60, 33, 48, 0, 27, 54, 51, 27, 90, 0, 60, 18, 24, 18, 54, 24, 36, 12, 42, 0, 87, 24, 33, 18, 24, 0, 96, 0, 87, 36, 30, 15, 42, 12, 36, 24, 24, 36, 42, 21, 48, 0, 30, 6, 42, 18, 48, 24, 24, 18, 84, 3, 36, 42, 42, 36, 72, 0, 54, 6, 30, 15, 60, 6, 78, 30, 24, 6, 72, 6, 66, 45, 24, 0, 42, 21, 36, 30, 36, 18, 48, 12, 30, 0, 39, 24, 102, 18, 36, 0, 12, 6, 54, 6, 30, 33, 66, 21, 90, 3, 78, 36, 9, 18, 36, 0, 84, 0, 30, 30, 93, 24, 30, 24, 30, 15, 63, 12, 48, 30, 54, 0, 48, 0, 54, 42, 42, 30, 78, 0, 36, 24, 39, 24, 60, 12, 78, 0, 60, 6, 51, 30, 36, 36, 30, 18, 60, 0, 30, 30, 51, 24, 60, 0, 42, 3, 24, 9, 54, 21, 24, 33, 30, 24, 66, 24, 69, 18, 30, 0, 102, 15, 54, 24, 15, 30, 120, 6, 30, 3, 51, 24, 54, 12, 30, 0, 36, 6, 36, 12, 90, 42, 12, 12, 60, 12, 60, 24, 42, 12, 90, 0, 24, 12, 42, 30, 30, 6, 78, 21, 42, 0, 54, 24, 27, 54, 24, 0, 66, 6, 45, 30, 12, 30, 42, 12, 84, 15, 36, 18, 84, 24, 36, 0, 30, 18, 72, 18, 60, 24, 48, 12, 54, 6, 36, 54, 42, 12, 42, 0, 60, 0, 51, 48, 54, 9, 36, 27, 24, 6, 84, 18, 48, 30, 42, 0, 78, 0, 48, 27, 27, 48, 42, 18, 36, 0, 39, 18, 99, 24, 102, 0, 18, 0, 48, 18, 72, 15, 36, 12, 84, 12, 24, 12, 30, 39, 84, 0, 36, 12, 39, 39, 63, 24, 42, 24, 66, 6, 72, 18, 18, 24, 30, 0, 60, 6, 48, 42, 36, 15, 78, 6, 48, 30, 12, 36, 54, 12, 36, 0, 42, 6, 45, 6, 69, 24, 72, 21, 48, 0, 57, 48, 12, 24, 48, 0, 48, 3, 48, 15, 78, 24, 60, 18, 12, 12, 111, 24, 54, 24, 24, 0, 48, 6, 36, 33, 42, 6, 54, 9, 72, 18, 27, 30, 30, 12, 54, 0, 66, 4, 78, 21, 24, 54, 18, 24, 54, 6, 60, 24, 54, 21, 78, 0, 36, 18, 54, 30, 66, 18, 48, 30, 24, 0, 42, 12, 99, 36, 30, 0, 90, 6, 18, 30, 30, 24, 78, 6, 66, 9, 24, 42, 78, 30, 42, 0, 18, 12, 102, 6, 33, 24, 18, 12, 66, 9, 54, 24, 24, 36, 84, 0, 60, 6, 39, 15, 78, 12, 42, 21, 42, 18, 42, 18, 18, 42, 24, 0, 48, 3, 105, 51, 42, 30, 42, 18, 72, 0, 24, 24, 102, 6, 36, 0, 36, 9, 99, 12, 48, 21, 48, 18, 42, 6, 36, 42, 18, 12, 78, 0, 48, 30, 30, 18, 36, 30, 42, 9, 42, 6, 60, 12, 39, 30, 24, 0, 78, 0, 48, 30, 39, 27, 102, 24, 30, 12, 51, 12, 66, 9, 48, 0, 30, 18, 45, 39, 87, 30, 36, 9, 72, 0, 60, 24, 30, 36, 54, 0, 48, 0, 45, 36, 45, 18, 42, 27, 60, 9, 66, 12, 78, 42, 18, 0, 60, 6, 60, 33, 36, 24, 96, 12, 18, 12, 12, 36, 72, 0, 78, 0, 36, 6, 60, 24, 27, 51, 42, 24, 84, 12, 57, 48, 30, 24, 42, 0, 60, 12, 24, 18, 96, 12, 30, 30, 30, 0, 93, 18, 48, 18, 60, 0, 48, 6, 54, 36, 30, 12, 42, 9, 60, 18, 12, 24, 69, 6, 60, 0, 54, 6, 33, 15, 60, 36, 30, 18, 90, 3, 72, 24, 54, 54, 42, 0, 18, 9, 60, 30, 84, 18, 48, 24, 12, 6, 66, 36, 24, 27, 24, 0, 42, 12, 39, 42, 27, 18, 108, 9, 78, 0, 48, 12, 54, 30, 30, 0, 36, 0, 48, 12, 75, 39, 30, 6, 42, 9, 66, 30, 33, 18, 96, 0, 48, 18, 39, 36, 102, 12, 54, 18, 24, 9, 45, 24, 72, 30, 36, 0, 78, 6, 63, 36, 36, 21, 60, 9, 36, 12, 54, 24, 78, 27, 42, 0, 42, 18, 60, 9, 24, 24, 54, 39, 84, 0, 27, 36, 39, 12, 84, 0, 66, 0, 21, 30, 30, 42, 66, 18, 18, 18, 78, 12, 48, 42, 36, 0, 90, 6, 48, 33, 39, 24, 48, 15, 54, 15, 54, 24, 48, 18, 60, 0, 24, 0, 48, 24, 78, 24, 36, 9, 90, 12, 42, 24, 30, 45, 54, 0, 66, 12, 24, 12, 60, 6, 48, 33, 48, 0, 60, 6, 51, 54, 12, 0, 30, 0, 69, 21, 42, 15, 72, 15, 48, 21, 33, 36, 96, 6, 30, 0, 54, 6, 87, 30, 42, 30, 36, 13, 42, 6, 84, 48, 18, 18, 72, 0, 54, 12, 30, 30, 75, 24, 36, 24, 42, 18, 78, 12, 36, 30, 72, 0, 48, 6, 33, 36, 57, 36, 66, 6, 54, 0, 27, 36, 66, 12, 90, 0, 24, 3, 96, 24, 27, 24, 18, 24, 108, 12, 42, 48, 24, 18, 30, 0, 54, 18, 48, 12, 75, 18, 90, 21, 36, 12, 72, 12, 45, 24, 24, 0, 114, 0, 27, 30, 39, 33, 48, 12, 54, 12, 18, 42, 45, 27, 48, 0, 48, 6, 90, 9, 60, 42, 36, 12, 48, 0, 36, 42, 42, 18, 78, 0, 30, 6, 24, 33, 78, 9, 84, 30, 18, 15, 63, 18, 51, 30, 48, 0, 72, 6, 36, 51, 24, 30, 48, 21, 96, 6, 24, 6, 93, 12, 48, 0, 18, 6, 69, 18, 36, 18, 24, 18, 24, 6, 54, 36, 51, 33, 96, 0, 36, 15, 27, 30, 54, 30, 42, 12, 36, 0, 117, 36, 54, 36, 24, 0, 96, 3, 72, 36, 57, 27, 54, 6, 54, 21, 36, 12, 66, 33, 60, 0, 30, 24, 24, 15, 63, 30, 42, 24, 78, 9, 39, 30, 24, 24, 138, 0, 42, 0, 54, 24, 57, 12, 30, 24, 42, 18, 54, 6, 60, 33, 24, 0, 72, 6, 84, 24, 42, 6, 66, 15, 36, 0, 42, 48, 51, 18, 66, 0, 60, 3, 60, 12, 60, 57, 42, 9, 72, 12, 60, 42, 27, 24, 60, 0, 42, 18, 24, 30, 48, 30, 36, 18, 30, 9, 78, 12, 51, 18, 30, 0, 60, 0, 12, 57, 51, 18, 78, 6, 102, 12, 30, 24, 48, 27, 36, 0, 30, 12, 126, 6, 27, 36, 30, 18, 66, 0, 60, 30, 48, 36, 48, 0, 24, 6, 39, 24, 96, 12, 90, 33, 36, 6, 39, 6, 90, 27, 36, 0, 60, 12, 45, 42, 30, 30, 72, 12, 36, 9, 39, 36, 69, 24, 48, 0, 36, 6, 66, 15, 72, 39, 36, 27, 54, 18, 57, 30, 42, 12, 60, 0, 84, 24, 36, 27, 72, 12, 48, 21, 60, 0, 51, 30, 27, 30, 90, 0, 78, 0, 42, 57, 12, 30, 48, 18, 42, 6, 48, 24, 90, 15, 42, 0, 12, 15, 84, 24, 72, 18, 48, 21, 66, 3, 54, 42, 30, 24, 48, 0, 36, 18, 27, 12, 42, 9, 108, 18, 36, 12, 96, 24, 21, 30, 24, 0, 96, 9, 54, 18, 75, 30, 54, 18, 36, 0, 39, 18, 84, 18, 42, 0, 24, 6, 54, 18, 57, 42, 24, 9, 84, 18, 48, 42, 27, 30, 78, 0, 60, 0, 30, 48, 36, 6, 30, 36, 6, 10, 78, 12, 51, 48, 48, 0, 90, 0, 75, 9, 42, 24, 48, 15, 72, 12, 33, 42, 108, 12, 54, 0, 54, 18, 51, 42, 36, 48, 48, 12, 72, 0, 42, 18, 45, 30, 66, 0, 78, 3, 36, 15, 78, 30, 30, 30, 30, 15, 102, 12, 54, 18, 30, 0, 36, 6, 81, 48, 12, 24, 108, 6, 78, 18, 24, 36, 33, 18, 30, 0, 30, 0, 108, 21, 54, 42, 18, 18, 90, 6, 30, 48, 69, 36, 48, 0, 24, 15, 24, 15, 84, 24, 114, 6, 30, 0, 48, 6, 60, 42, 24, 0, 102, 12, 42, 42, 27, 21, 78, 9, 42, 24, 51, 24, 42, 12, 48, 0, 60, 12, 66, 6, 42, 24, 30, 24, 42, 0, 78, 24, 54, 12, 66, 0, 30, 6, 24, 51, 99, 18, 60, 24, 42, 18, 54, 6, 45, 60, 36, 0, 54, 6, 39, 39, 39, 30, 66, 18, 72, 0, 51, 24, 102, 12, 54, 0, 24, 0, 102, 12, 48, 24, 42, 36, 60, 0, 12, 48, 18, 12, 54, 0, 84, 18, 39, 9, 84, 30, 66, 18, 48, 15, 72, 48, 39, 42, 48, 0, 60, 0, 84, 30, 45, 33, 54, 6, 54, 30, 33, 30, 90, 6, 54, 0, 24, 6, 72, 27, 78, 12, 24, 15, 66, 0, 54, 36, 21, 42, 114, 0, 60, 3, 30, 33, 54, 27, 30, 33, 60, 6, 54, 12, 48, 33, 36, 0, 42, 12, 45, 39, 24, 36, 96, 18, 24, 12, 33, 18, 99, 18, 66, 0, 36, 0, 51, 24, 30, 30, 36, 15, 84, 6, 102, 48, 48, 18, 60, 0, 72, 12, 36, 42, 60, 12, 24, 21, 30, 0, 54, 18, 60, 18, 42, 0, 66, 6, 24, 24, 54, 15, 78, 12, 42, 27, 27, 30, 51, 27, 78, 0, 48, 6, 120, 27, 48, 42, 24, 12, 54, 6, 54, 24, 48, 36, 66, 0, 78, 9, 57, 21, 48, 18, 54, 33, 24, 30, 84, 18, 45, 33, 30, 0, 126, 9, 36, 30, 27, 30, 66, 18, 54, 0, 36, 42, 48, 6, 42, 0, 54, 6, 57, 12, 84, 54, 48, 6, 60, 6, 63, 18, 42, 36, 78, 0, 24, 24, 33, 24, 105, 24, 66, 27, 48, 0, 48, 30, 60, 30, 54, 0, 42, 3, 75, 48, 24, 12, 66, 12, 96, 6, 30, 12, 87, 21, 36, 0, 30, 24, 69, 12, 57, 30, 48, 24, 54, 0, 42, 54, 24, 24, 72, 0, 60, 0, 48, 24, 69, 24, 42, 18, 36, 12, 66, 24, 36, 42, 18, 0, 78, 9, 48, 36, 42, 42, 36, 12, 36, 21, 78, 18, 48, 12, 102, 0, 18, 12, 54, 24, 45, 27, 42, 13, 108, 12, 39, 24, 42, 27, 102, 0, 60, 6, 39, 24, 54, 12, 54, 24, 24, 0, 114, 24, 63, 48, 30, 0, 48, 6, 69, 36, 18, 12, 72, 6, 48, 18, 33, 54, 117, 12, 42, 0, 66, 12, 48, 6, 54, 36, 42, 21, 102, 6, 48, 54, 33, 30, 48, 0, 72, 0, 30, 24, 75, 24, 84, 30, 30, 0, 72, 18, 30, 42, 54, 0, 60, 12, 36, 45, 42, 12, 96, 6, 66, 0, 12, 36, 78, 36, 42, 0, 36, 0, 78, 24, 48, 24, 18, 30, 90, 15, 96, 18, 27, 21, 54, 0, 24, 21, 48, 27, 84, 18, 48, 42, 36, 6, 66, 12, 108, 12, 42, 0, 48, 9, 27, 60, 21, 36, 84, 6, 36, 18, 42, 18, 54, 18, 60, 0, 60, 15, 72, 9, 99, 42, 12, 12, 60, 0, 57, 42, 18, 18, 78, 0, 42, 6, 36, 36, 63, 9, 42, 15, 30, 18, 78, 6, 24, 48, 42, 0, 102, 12, 75, 45, 42, 30, 84, 24, 66, 9, 24, 30, 90, 24, 42, 0, 24, 3, 84, 21, 84, 33, 66, 24, 36, 6, 36, 48, 51, 18, 72, 0, 66, 18, 54, 30, 24, 18, 48, 18, 30, 0, 102, 12, 45, 36, 24, 0, 102, 3, 42, 15, 42, 54, 54, 21, 66, 24, 66, 30, 102, 3, 66, 0, 48, 12, 24, 30, 45, 36, 54, 6, 78, 9, 48, 24, 39, 36, 96, 0, 66, 6, 27, 27, 60, 30, 18, 30, 48, 12, 90, 24, 60, 36, 6, 0, 42, 12, 78, 36, 36, 24, 114, 6, 60, 0, 18, 6, 69, 18, 84, 0, 36, 6, 48, 6, 39, 24, 42, 24, 54, 6, 72, 48, 36, 42, 60, 0, 48, 0, 36, 18, 138, 24, 30, 30, 42, 18, 75, 18, 48, 18, 24, 0, 78, 0, 78, 57, 60, 9, 48, 9, 36, 30, 30, 42, 42, 39, 84, 0, 24, 12, 87, 27, 30, 42, 24, 24, 90, 0, 36, 24, 60, 36, 84, 0, 42, 0, 30, 21, 87, 12, 72, 24, 42, 12, 60, 30, 72, 21, 60, 0, 96, 12, 30, 42, 39, 18, 66, 12, 84, 12, 63, 42, 42, 24, 42, 0, 18, 6, 78, 15, 75, 45, 54, 12, 54, 6, 84, 30, 30, 18, 54, 0, 42, 24, 39, 27, 96, 18, 42, 21, 48, 0, 54, 18, 33, 36, 66, 0, 84, 0, 75, 48, 30, 42, 54, 12, 54, 15, 42, 30, 96, 18, 42, 0, 18, 6, 123, 15, 48, 24, 48, 39, 42, 6, 21, 54, 45, 12, 60, 0, 90, 12, 30, 36, 45, 18, 72, 21, 78, 12, 30, 12, 60, 30, 18, 0, 78, 6, 60, 36, 33, 18, 60, 12, 30, 0, 60, 18, 90, 30, 54, 0, 36, 1, 78, 27, 84, 30, 18, 15, 102, 9, 27, 30, 24, 57, 90, 0, 42, 9, 48, 42, 42, 12, 72, 27, 48, 9, 108, 18, 48, 48, 18, 0, 84, 6, 66, 24, 48, 21, 114, 6, 78, 24, 30, 30, 42, 18, 60, 0, 18, 12, 63, 9, 51, 66, 48, 15, 54, 0, 66, 60, 36, 18, 48, 0, 66, 6, 36, 30, 96, 9, 36, 30, 30, 24, 93, 24, 72, 24, 66, 0, 60, 24, 48, 30, 24, 30, 72, 6, 60, 12, 30, 12, 93, 18, 72, 0, 30, 0, 81, 30, 36, 48, 36, 30, 90, 6, 54, 24, 57, 24, 36, 0, 54, 18, 36, 24, 78, 18, 72, 33, 12, 0, 51, 30, 48, 24, 42, 0, 90, 3, 78, 30, 30, 27, 138, 6, 30, 18, 36, 24, 75, 24, 12, 0, 54, 12, 42, 18, 84, 36, 30, 18, 66, 6, 45, 36, 36, 48, 114, 0, 24, 6, 30, 21, 108, 15, 48, 18, 36, 18, 57, 24, 63, 42, 54, 0, 78, 6, 81, 36, 18, 24, 42, 18, 120, 0, 24, 24, 66, 12, 54, 0, 48, 12, 66, 18, 42, 36, 48, 18, 72, 6, 48, 48, 33, 6, 102, 0, 54, 24, 39, 54, 60, 12, 90, 18, 36, 3, 111, 24, 51, 48, 42, 0, 90, 0, 45, 36, 54, 48, 54, 24, 18, 18, 51, 18, 72, 0, 54, 0, 18, 12, 54, 36, 57, 18, 42, 18, 120, 0, 63, 42, 27, 36, 48, 0, 54, 6, 39, 30, 81, 18, 72, 33, 54, 9, 72, 12, 54, 54, 24, 0, 54, 15, 75, 24, 60, 12, 78, 6, 30, 12, 39, 54, 72, 6, 54, 0, 72, 6, 78, 12, 54, 39, 30, 15, 48, 6, 57, 48, 18, 24, 90, 0, 90, 18, 42, 24, 39, 42, 24, 30, 42, 0, 84, 6, 66, 30, 30, 0, 30, 0, 27, 42, 39, 33, 90, 24, 84, 18, 51, 36, 69, 24, 54, 0, 42, 18, 87, 33, 51, 18, 42, 9, 126, 9, 84, 36, 66, 18, 54, 0, 36, 0, 66, 12, 48, 15, 54, 30, 18, 18, 60, 18, 96, 54, 42, 0, 102, 0, 27, 36, 30, 36, 108, 15, 54, 0, 24, 36, 60, 24, 66, 0, 30, 0, 54, 15, 75, 48, 36, 18, 48, 24, 36, 36, 54, 15, 108, 0, 84, 18}; for (int i = 0; i < a; i++) { cout << n[i] << endl; } }
replace
5
17
5
631
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) (a).begin(), (a).end() typedef vector<int> vi; const int INF = 1LL << 60; // 10e18+10e17ちょっとくらい const int MOD = 1000000007; const int MAX_N = 200100; signed main() { // 以降 cin の入力元が 'input.txt' になる // std::ifstream in("input.txt"); // std::cin.rdbuf(in.rdbuf()); int n; cin >> n; vi ans(n + 1); rep(i, n + 1) { ans[i] == 0; } for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { ans[x * x + y * y + z * z + x * y + y * z + z * x]++; } } } rep(i, n) { cout << ans[i + 1] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) (a).begin(), (a).end() typedef vector<int> vi; const int INF = 1LL << 60; // 10e18+10e17ちょっとくらい const int MOD = 1000000007; const int MAX_N = 200100; signed main() { // 以降 cin の入力元が 'input.txt' になる // std::ifstream in("input.txt"); // std::cin.rdbuf(in.rdbuf()); int n; cin >> n; vi ans(n + 1); rep(i, n + 1) { ans[i] == 0; } for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x <= n) ans[x * x + y * y + z * z + x * y + y * z + z * x]++; } } } rep(i, n) { cout << ans[i + 1] << endl; } return 0; }
replace
22
23
22
24
-11
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int ans[30000]; int main() { int n; scanf("%d", &n); int t = (int)sqrt(n) + 1; for (int i = 1; i <= t; i++) { for (int j = 1; j <= t; j++) { for (int z = 1; z <= t; z++) { ans[i * i + j * j + z * z + i * j + j * z + i * z]++; } } } for (int i = 1; i <= n; i++) printf("%d\n", ans[i]); }
#include <bits/stdc++.h> using namespace std; int ans[30000]; int main() { int n; scanf("%d", &n); int t = (int)sqrt(n) + 1; for (int i = 1; i <= t; i++) { for (int j = 1; j <= t; j++) { for (int z = 1; z <= t; z++) { if (i * i + j * j + z * z + i * j + j * z + i * z <= n) ans[i * i + j * j + z * z + i * j + j * z + i * z]++; } } } for (int i = 1; i <= n; i++) printf("%d\n", ans[i]); }
replace
10
11
10
12
0
p02608
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n, ans; cin >> n; for (int index = 0; index < n; index++) { ans = 0; for (int i = 1; i < 75; i++) { for (int j = 1; j < 75; j++) { for (int k = 1; k < 75; k++) { if (i * i + j * j + k * k + i * j + j * k + k * i == index + 1) ans++; } } } printf("%d\n", ans); } return 0; }
#include <iostream> using namespace std; int main() { int n, ans; cin >> n; for (int index = 0; index < n; index++) { ans = 0; for (int i = 1; i < 100; i++) { for (int j = i; j < 100; j++) { for (int k = j; k < 100; k++) { if (i * i + j * j + k * k + i * j + j * k + k * i == index + 1) { if (i != j && j != k) ans += 6; else if ((i == j || i == k || j == k) && !(i == j && i == k)) ans += 3; else if (i == j && i == k) ans++; } } } } printf("%d\n", ans); } return 0; }
replace
9
14
9
20
TLE
p02608
C++
Time Limit Exceeded
#include <algorithm> #include <assert.h> #include <bits/stdc++.h> #include <bits/stdtr1c++.h> #include <bitset> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <utility> #include <vector> using namespace std; typedef long long ll; const int N = 100005; const int MOD = 1000000007; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n + 1]; for (int i = 0; i <= n; i++) a[i] = 0; for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - 1; j++) { for (int k = 1; k <= n - 1; k++) { int sum = i * i + j * j + k * k + i * j + j * k + k * i; if (sum <= n) a[sum]++; } } } for (int i = 1; i <= n; i++) cout << a[i] << endl; }
#include <algorithm> #include <assert.h> #include <bits/stdc++.h> #include <bits/stdtr1c++.h> #include <bitset> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <utility> #include <vector> using namespace std; typedef long long ll; const int N = 100005; const int MOD = 1000000007; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n + 1]; for (int i = 0; i <= n; i++) a[i] = 0; for (int i = 1; i * i <= n - 1; i++) { for (int j = 1; j * j <= n - 1; j++) { for (int k = 1; k * k <= n - 1; k++) { int sum = i * i + j * j + k * k + i * j + j * k + k * i; if (sum <= n) a[sum]++; } } } for (int i = 1; i <= n; i++) cout << a[i] << endl; }
replace
40
43
40
43
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // #define int long long typedef long long ll; // const int INF = 2e9; // const ll INF = 9e18; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> f(N + 1); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { for (int n = 1; n <= N; n++) { if (x * x + y * y + z * z + x * y + y * z + z * x == n) { f[n]++; } } } } } for (int n = 1; n <= N; n++) { cout << f[n] << "\n"; } }
#include <bits/stdc++.h> using namespace std; // #define int long long typedef long long ll; // const int INF = 2e9; // const ll INF = 9e18; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> f(N + 1); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int p = x * x + y * y + z * z + x * y + y * z + z * x; if (p <= N) f[p]++; } } } for (int n = 1; n <= N; n++) { cout << f[n] << "\n"; } }
replace
17
22
17
20
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int n; cin >> n; vector<int> ans(n + 1, 0); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int sum = x * x + y * y + z * z + x * y + y * z + z * x; ans[sum]++; } } } for (int i = 1; i <= n; i++) cout << ans[i] << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int n; cin >> n; vector<int> ans(1e5, 0); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int sum = x * x + y * y + z * z + x * y + y * z + z * x; ans[sum]++; } } } for (int i = 1; i <= n; i++) cout << ans[i] << endl; }
replace
7
8
7
8
-11
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int c[105][105]; int main() { int n; cin >> n; for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { c[i][j] = (i + j) * (i + j); } } for (int i = 1; i <= n; i++) { int d = i << 1; int cnt = 0; for (int x = 1; x <= sqrt(i); x++) { for (int y = 1; y <= sqrt(i); y++) { for (int z = 1; z <= sqrt(i); z++) { if (c[x][y] + c[x][z] + c[y][z] == d) cnt++; } } } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int c[105][105]; int main() { int n; cin >> n; for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { c[i][j] = (i + j) * (i + j); } } for (int i = 1; i <= n; i++) { int d = i << 1; int cnt = 0; for (int x = 1; x <= sqrt(i); x++) { for (int y = x; y <= sqrt(i); y++) { for (int z = y; z <= sqrt(i); z++) { if (c[x][y] + c[x][z] + c[y][z] == d) { if (x == y && y == z) cnt++; else if (x != y && y != z && x != z) cnt += 6; else cnt += 3; } } } } cout << cnt << endl; } return 0; }
replace
15
19
15
25
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using ll = long long; using namespace std; const int INFint = 1e9 + 1; const ll INFll = (ll)1e18 + 1; ll MOD = 1e9 + 7; int main() { int N; cin >> N; int cnt[1001] = {0}; for (int i(1); i <= 100; i++) { for (int j(1); j <= 100; j++) { for (int k(1); k <= 100; k++) { int x = i * i + j * j + k * k + i * j + j * k + k * i; if (x <= N) { cnt[x]++; } } } } for (int i(1); i <= N; i++) { cout << cnt[i] << endl; } return 0; }
#include <bits/stdc++.h> using ll = long long; using namespace std; const int INFint = 1e9 + 1; const ll INFll = (ll)1e18 + 1; ll MOD = 1e9 + 7; int main() { int N; cin >> N; int cnt[10001] = {0}; for (int i(1); i <= 100; i++) { for (int j(1); j <= 100; j++) { for (int k(1); k <= 100; k++) { int x = i * i + j * j + k * k + i * j + j * k + k * i; if (x <= N) { cnt[x]++; } } } } for (int i(1); i <= N; i++) { cout << cnt[i] << endl; } return 0; }
replace
11
12
11
12
0
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long #define P pair<ll, ll> #define all(v) (v).begin(), (v).end() const ll mod = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1.0); int main(void) { ll n; cin >> n; vector<ll> s(10050, 0); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { ll x = i * i + j * j + k * k + i * j + j * k + k * i; // if(x > n) continue; s[x]++; } } } rep(i, n) cout << s[i + 1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define ll long long #define P pair<ll, ll> #define all(v) (v).begin(), (v).end() const ll mod = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1.0); int main(void) { ll n; cin >> n; vector<ll> s(10050, 0); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { ll x = i * i + j * j + k * k + i * j + j * k + k * i; if (x <= n) s[x]++; } } } rep(i, n) cout << s[i + 1] << endl; return 0; }
replace
20
22
20
22
-11
p02608
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++) #define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--) #define all(a) (a.begin()), (a.end()) #define rall(a) (a.rbegin()), (a.rend()) #define fi first #define se second #define pb push_back #define eb emplace_back using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vector<int>>; using P = pair<int, int>; int f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } void Main() { int n; cin >> n; int m = sqrt(n + 1); vi ans(n + 1, 0); rep3(i, 1, m) rep3(j, 1, m) rep3(k, 1, m) { int now = f(i, j, k); ans[now]++; } rep3(i, 1, n) cout << ans[i] << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++) #define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--) #define all(a) (a.begin()), (a.end()) #define rall(a) (a.rbegin()), (a.rend()) #define fi first #define se second #define pb push_back #define eb emplace_back using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vector<int>>; using P = pair<int, int>; int f(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } void Main() { int n; cin >> n; int m = sqrt(n + 1); vi ans(n + 1, 0); rep3(i, 1, m) rep3(j, 1, m) rep3(k, 1, m) { int now = f(i, j, k); if (0 < now && now <= n) ans[now]++; } rep3(i, 1, n) cout << ans[i] << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
replace
31
32
31
33
0
p02608
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int x = 1; x * x < N; ++x) { for (int y = 1; x * x + y * y < N; ++y) { for (int z = 1; x + x + y * y + z * z < N; ++z) { int v = x * x + y * y + z * z + x * y + y * z + z * x; ++A[v - 1]; } } } for (auto e : A) cout << e << "\n"; }
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int x = 1; x * x < N; ++x) { for (int y = 1; x * x + y * y < N; ++y) { for (int z = 1; x + x + y * y + z * z < N; ++z) { int v = x * x + y * y + z * z + x * y + y * z + z * x; if (v > N) continue; ++A[v - 1]; } } } for (auto e : A) cout << e << "\n"; }
insert
13
13
13
15
-6
malloc(): corrupted top size
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //(a+b-1)/b signed main() { ll n; cin >> n; vl v(1e7); for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= n; j++) { for (ll k = 1; k <= n; k++) { ll h = (i + j + k); h *= h; h -= (i * j) + (j * k) + (i * k); if (h <= n) v[h]++; } } } rep(i, 1, n + 1) { cout << v[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //(a+b-1)/b signed main() { ll n; cin >> n; vl v(1e7); for (ll i = 1; i <= 100; i++) { for (ll j = 1; j <= 100; j++) { for (ll k = 1; k <= 100; k++) { ll h = (i + j + k); h *= h; h -= (i * j) + (j * k) + (i * k); if (h <= n) v[h]++; } } } rep(i, 1, n + 1) { cout << v[i] << endl; } return 0; }
replace
31
34
31
34
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; int main() { int n; cin >> n; vi cnt(n, 0); int c = sqrt(n) + 1; for (int x = 1; x <= c + 1; x++) { for (int y = 1; y <= c + 1; y++) { for (int z = 1; z <= c + 1; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x <= n) cnt.at(x * x + y * y + z * z + x * y + y * z + z * x)++; } } } for (int x : cnt) cout << x << endl; }
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; int main() { int n; cin >> n; vi cnt(n, 0); int c = sqrt(n) + 1; for (int x = 1; x <= c + 1; x++) { for (int y = 1; y <= c + 1; y++) { for (int z = 1; z <= c + 1; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x <= n) cnt.at(x * x + y * y + z * z + x * y + y * z + z * x - 1)++; } } } for (int x : cnt) cout << x << endl; }
replace
13
14
13
14
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define rep(i, n) for (ll i = 0; i < (ll)n; i++) int main() { ll n; cin >> n; map<ll, ll> mp; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= n; k++) { mp[i * i + j * j + k * k + i * j + j * k + k * i]++; } } } for (int i = 1; i <= n; i++) { cout << mp[i] << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define rep(i, n) for (ll i = 0; i < (ll)n; i++) int main() { ll n; cin >> n; map<ll, ll> mp; for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { mp[i * i + j * j + k * k + i * j + j * k + k * i]++; } } } for (int i = 1; i <= n; i++) { cout << mp[i] << endl; } }
replace
10
13
10
13
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; vector<int> ans(10004, 0); cin >> n; for (int i = 1; i * i <= n; ++i) { for (int j = 1; j * j <= n; ++j) { for (int k = 1; k * k <= n; ++k) { int sum = i * i + j * j + k * k + i * j + j * k + k * i; ans[sum]++; } } } for (int i = 1; i <= n; ++i) { cout << ans[i] << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; vector<int> ans(10004, 0); cin >> n; for (int i = 1; i * i <= n; ++i) { for (int j = 1; j * j <= n; ++j) { for (int k = 1; k * k <= n; ++k) { int sum = i * i + j * j + k * k + i * j + j * k + k * i; if (sum <= 10000) ans[sum]++; } } } for (int i = 1; i <= n; ++i) { cout << ans[i] << '\n'; } return 0; }
replace
10
11
10
12
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int f[10001]; for (int i = 1; i <= n; i++) f[i] = 0; for (int i = 0; i < 5; i++) { cout << 0 << endl; if (i + 1 >= n) break; } for (int i = 6; i <= n; i++) { for (int x = 1; x * x <= i; x++) { for (int y = 1; y * y <= i; y++) { for (int z = 1; z * z <= i; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) f[i]++; } } } cout << f[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int f[10001]; for (int i = 1; i <= n; i++) f[i] = 0; for (int i = 0; i < 5; i++) { cout << 0 << endl; if (i + 1 >= n) break; } for (int i = 6; i <= n; i++) { for (int x = 1; x * x < i; x++) { for (int y = 1; y * y <= i - x * x; y++) { double z = (-1 * (x + y) + sqrt(-3 * x * x - 3 * y * y - 2 * x * y + 4 * i)) / 2; if (floor(z) == z && z > 0) f[i]++; } } cout << f[i] << endl; } }
replace
17
23
17
24
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vc = vector<char>; using vb = vector<bool>; using vd = vector<double>; vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1}; int main() { ll n; cin >> n; vl ans(n + 1, 0); rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) { ll now = x * x + y * y + z * z + x * y + y * z + z * x; ans[now]++; } rep2(i, 1, n + 1) cout << ans[i] << '\n'; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vc = vector<char>; using vb = vector<bool>; using vd = vector<double>; vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1}; int main() { ll n; cin >> n; vl ans(n + 1, 0); rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) { ll now = x * x + y * y + z * z + x * y + y * z + z * x; if (now <= n) ans[now]++; } rep2(i, 1, n + 1) cout << ans[i] << '\n'; }
replace
21
22
21
23
-11
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int main() { vector<int> f(10000); int N; cin >> N; int n = sqrt(N); for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { for (int z = 1; z <= n; z++) { int F = x * x + y * y + z * z + x * y + y * z + z * x; f[F - 1]++; } } } for (int i = 0; i < N; i++) { cout << f[i] << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int main() { vector<int> f(60000); int N; cin >> N; int n = sqrt(N); for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { for (int z = 1; z <= n; z++) { int F = x * x + y * y + z * z + x * y + y * z + z * x; f[F - 1]++; } } } for (int i = 0; i < N; i++) { cout << f[i] << endl; } }
replace
6
7
6
7
0
p02608
C++
Runtime Error
// // Created by 10940 on 2020/7/11. // #include <bits/stdc++.h> using namespace std; // #define LOCAL int a[10005]; int fun(int num) { int ans = 0; for (int i = 1; i * i <= num; i++) { for (int j = 1; j * j <= num; j++) { for (int k = 1; k * k <= num; k++) { int re = i * i + j * j + k * k + i * j + j * k + i * k; if (re <= num) { a[re]++; } } } } } int main() { /*#ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif*/ int N; cin >> N; fun(N); for (int i = 1; i <= N; i++) { cout << a[i] << endl; } /*printf("Time used = %.3fs\n", (double) clock() / CLOCKS_PER_SEC); printf("Time used = %dms", clock());*/ return 0; }
// // Created by 10940 on 2020/7/11. // #include <bits/stdc++.h> using namespace std; // #define LOCAL int a[10005]; void fun(int num) { int ans = 0; for (int i = 1; i * i <= num; i++) { for (int j = 1; j * j <= num; j++) { for (int k = 1; k * k <= num; k++) { int re = i * i + j * j + k * k + i * j + j * k + i * k; if (re <= num) { a[re]++; } } } } } int main() { /*#ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif*/ int N; cin >> N; fun(N); for (int i = 1; i <= N; i++) { cout << a[i] << endl; } /*printf("Time used = %.3fs\n", (double) clock() / CLOCKS_PER_SEC); printf("Time used = %dms", clock());*/ return 0; }
replace
10
11
10
11
0
p02608
C++
Runtime Error
#include <iostream> using namespace std; int main() { int N, x, y, z, i; cin >> N; int count[1000000]; for (i = 1; i <= N; i++) { count[i] = 0; } for (x = 1; x <= N; ++x) { for (y = 1; y <= N; ++y) { for (z = 1; z <= N; ++z) { count[x * x + y * y + z * z + x * y + x * z + y * z]++; } } } for (i = 1; i <= N; ++i) { cout << count[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int N, x, y, z, i; cin >> N; int count[1000000]; for (i = 1; i <= N; i++) { count[i] = 0; } for (x = 1; x <= 100; ++x) { for (y = 1; y <= 100; ++y) { for (z = 1; z <= 100; ++z) { count[x * x + y * y + z * z + x * y + x * z + y * z]++; } } } for (i = 1; i <= N; ++i) { cout << count[i] << endl; } return 0; }
replace
10
13
10
13
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); ++(i)) const int INF = 1001001001; int main() { int n; cin >> n; vector<int> vec1(n); int temp; int count = 0; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { for (int k = j; k <= n; k++) { temp = i * i + j * j + k * k + i * j + j * k + i * k; if (i <= j && j <= k) { if (temp <= n) { if (i == j && j == k) { vec1[temp - 1]++; } else if (i == j || j == k || k == i) { vec1[temp - 1] += 3; } else { vec1[temp - 1] += 6; } } } } } } rep(i, n) cout << vec1[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); ++(i)) const int INF = 1001001001; int main() { int n; cin >> n; vector<int> vec1(n); int temp; int count = 0; double sn = sqrt(n); for (int i = 1; i < sn; i++) { for (int j = i; j < sn; j++) { for (int k = j; k < sn; k++) { temp = i * i + j * j + k * k + i * j + j * k + i * k; if (i <= j && j <= k) { if (temp <= n) { if (i == j && j == k) { vec1[temp - 1]++; } else if (i == j || j == k || k == i) { vec1[temp - 1] += 3; } else { vec1[temp - 1] += 6; } } } } } } rep(i, n) cout << vec1[i] << endl; return 0; }
replace
12
15
12
16
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int i, n, k, j, u; int a[1010]; int main() { cin >> n; for (i = 1; i < sqrt(n); i++) { for (j = 1; j < sqrt(n); j++) { for (k = 1; k < sqrt(n); k++) { u = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k; if (u <= n) a[u]++; } } } for (i = 1; i <= n; i++) cout << a[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int i, n, k, j, u; int a[10010]; int main() { cin >> n; for (i = 1; i < sqrt(n); i++) { for (j = 1; j < sqrt(n); j++) { for (k = 1; k < sqrt(n); k++) { u = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k; if (u <= n) a[u]++; } } } for (i = 1; i <= n; i++) cout << a[i] << endl; return 0; }
replace
3
4
3
4
0
p02608
C++
Runtime Error
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define ll long long #define eps 1e-7 #define all(x) ((x).begin()), ((x).end()) #define usecppio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; #define int ll using pii = pair<int, int>; int ans[10101]; int32_t main() { int n; cin >> n; for (int x = 1; x * x <= n; x++) { for (int y = 1; y * y <= n; y++) { for (int z = 1; z * z <= n; z++) { int u = x * x + y * y + z * z + x * y + y * z + z * x; ans[u]++; } } } for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; }
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define ll long long #define eps 1e-7 #define all(x) ((x).begin()), ((x).end()) #define usecppio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; #define int ll using pii = pair<int, int>; int ans[100101]; int32_t main() { int n; cin >> n; for (int x = 1; x * x <= n; x++) { for (int y = 1; y * y <= n; y++) { for (int z = 1; z * z <= n; z++) { int u = x * x + y * y + z * z + x * y + y * z + z * x; ans[u]++; } } } for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; }
replace
15
16
15
16
0
p02608
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; int f[1010]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { long long sum = i * i + j * j + k * k + i * j + i * k + j * k; if (sum <= n) f[(int)sum]++; } } } for (int i = 1; i <= n; i++) printf("%d\n", f[i]); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; int f[10010]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { for (int k = 1; k <= 100; k++) { long long sum = i * i + j * j + k * k + i * j + i * k + j * k; if (sum <= n) f[(int)sum]++; } } } for (int i = 1; i <= n; i++) printf("%d\n", f[i]); return 0; }
replace
7
8
7
8
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define all(n) begin(n), end(n) struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; const long long INF = numeric_limits<long long>::max(); int main() { int N; cin >> N; // 愚直に探す // N<10000よりx<=y<=zとするとxは最高でも100 int ans = 0; for (int i = 1; i <= N; i++) { ans = 0; for (int x = 1; x <= 100; x++) { for (int y = x; y <= 100; y++) { for (int z = y; z <= 100; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) { if (x == y && y == z) { ans++; } else if (x != y && y == z) { ans += 3; } else if (x == y && y != z) { ans += 3; } else { ans += 6; } } else if (x * x + y * y + z * z + x * y + y * z + z * x > i) { continue; } } } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define all(n) begin(n), end(n) struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; const long long INF = numeric_limits<long long>::max(); int main() { int N; cin >> N; // 愚直に探す // N<10000よりx<=y<=zとするとxは最高でも100 int ans = 0; for (int i = 1; i <= N; i++) { ans = 0; for (int x = 1; x <= 100; x++) { for (int y = x; y <= 100; y++) { for (int z = y; z <= 100; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) { if (x == y && y == z) { ans++; } else if (x != y && y == z) { ans += 3; } else if (x == y && y != z) { ans += 3; } else { ans += 6; } } else if (x * x + y * y + z * z + x * y + y * z + z * x > i) { break; } } } } cout << ans << endl; } return 0; }
replace
37
38
37
38
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP2(i, x, n) for (int i = x; i < (int)(n); i++) #define ALL(n) begin(n), end(n) // struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star; const long long INF = numeric_limits<long long>::max(); typedef long long ll; int main() { int n; scanf("%d", &n); int x = 1; int y = 1; int z = 1; int num; int max; int ans; for (int i = 1; i <= n; ++i) { max = (int)sqrtf(n - 5) + 2; num = 0; for (x = 1; x <= max; ++x) { for (y = 1; y <= x; ++y) { for (z = 1; z <= y; ++z) { ans = x * x + y * y + z * z + x * y + y * z + z * x; if (ans == i) { if (x == y && y == z) { ++num; } else if (x == y && y != z) { num += 3; } else if (x != y && y == z) { num += 3; } else { num += 6; } } else if (ans > i) { continue; } } } } printf("%d\n", num); } return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP2(i, x, n) for (int i = x; i < (int)(n); i++) #define ALL(n) begin(n), end(n) // struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star; const long long INF = numeric_limits<long long>::max(); typedef long long ll; int main() { int n; scanf("%d", &n); int x = 1; int y = 1; int z = 1; int num; int max; int ans; for (int i = 1; i <= n; ++i) { max = (int)sqrtf(n - 5) + 2; num = 0; for (x = 1; x <= max; ++x) { for (y = 1; y <= x; ++y) { for (z = 1; z <= y; ++z) { ans = x * x + y * y + z * z + x * y + y * z + z * x; if (ans == i) { if (x == y && y == z) { ++num; } else if (x == y && y != z) { num += 3; } else if (x != y && y == z) { num += 3; } else { num += 6; } } else if (ans > i) { break; } } } } printf("%d\n", num); } return 0; }
replace
38
39
38
39
TLE
p02608
C++
Time Limit Exceeded
// It doesn't matter as long as you rise to the top - Katsuki Bakugo #include <bits/stdc++.h> using namespace std; #define Fast_as_duck \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define forn(i, st, n) for (int i = st; i < n; i++) #define rev(i, st, n) for (int i = st; i >= n; i--) #define ss second #define ff first #define ll long long typedef pair<int, int> pii; const int N = 1e5 + 10, mod = 1000000007; void solve() { int num; cin >> num; forn(n, 1, num + 1) { int ans = 0; forn(x, 1, n) { forn(y, 1, n) { ll c = (ll)n - x * x - y * y - x * y; ll b = (x + y); ll d = b * b + 4 * c; ll rootd = sqrt(d); if (rootd * rootd != d) { continue; } if (rootd > b && (rootd - b) % 2 == 0) ans++; // forn(z,1,n){ // if(x*x + y*y + z*z + x*y + y*z + z*x == n ){ // ans++; // } // if(x*x + y*y + z*z + x*y + y*z + z*x > n ){ // break; // } // } } } cout << ans << "\n"; } } int main() { Fast_as_duck; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; // cin >> t; while (t--) { solve(); } return 0; }
// It doesn't matter as long as you rise to the top - Katsuki Bakugo #include <bits/stdc++.h> using namespace std; #define Fast_as_duck \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define forn(i, st, n) for (int i = st; i < n; i++) #define rev(i, st, n) for (int i = st; i >= n; i--) #define ss second #define ff first #define ll long long typedef pair<int, int> pii; const int N = 1e5 + 10, mod = 1000000007; void solve() { int num; cin >> num; forn(n, 1, num + 1) { int ans = 0; forn(x, 1, sqrt(n)) { forn(y, 1, sqrt(n)) { ll c = (ll)n - x * x - y * y - x * y; ll b = (x + y); ll d = b * b + 4 * c; ll rootd = sqrt(d); if (rootd * rootd != d) { continue; } if (rootd > b && (rootd - b) % 2 == 0) ans++; // forn(z,1,n){ // if(x*x + y*y + z*z + x*y + y*z + z*x == n ){ // ans++; // } // if(x*x + y*y + z*z + x*y + y*z + z*x > n ){ // break; // } // } } } cout << ans << "\n"; } } int main() { Fast_as_duck; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; // cin >> t; while (t--) { solve(); } return 0; }
replace
28
30
28
30
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int ans = 0; for (int x = 1; x <= floor(sqrt(n)); x++) { for (int y = 1; y <= floor(sqrt(n - x * x)); y++) { for (int z = 1; z <= floor(sqrt(n - x * x - y * y - x * y)); z++) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) ans++; } } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int ans = 0; for (int x = 1; x * x + 2 * x + 3 <= i; x++) { for (int y = 1; x * x + y * y + 1 + x * y + y + x <= i; y++) { for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= i; z++) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) ans++; } } } cout << ans << endl; } return 0; }
replace
7
10
7
11
TLE
p02608
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int64_t> f(N); for (int i = 0; i < N; i++) { f.at(i) = 0; } for (int j = 1; j < 101; j++) { for (int k = 1; k < 101; k++) { for (int l = 1; l < 101; l++) { if (j * j + k * k + l * l + j * k + k * l + l * j <= N) { f.at(j * j + k * k + l * l + j * k + k * l + l * j) = f.at(j * j + k * k + l * l + j * k + k * l + l * j) + 1; } } } } for (int n = 0; n < N; n++) { cout << f.at(n) << endl; } }
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int64_t> f(N); for (int i = 0; i < N; i++) { f.at(i) = 0; } for (int j = 1; j < 101; j++) { for (int k = 1; k < 101; k++) { for (int l = 1; l < 101; l++) { if (j * j + k * k + l * l + j * k + k * l + l * j <= N) { f.at(j * j + k * k + l * l + j * k + k * l + l * j - 1) = f.at(j * j + k * k + l * l + j * k + k * l + l * j - 1) + 1; } } } } for (int n = 0; n < N; n++) { cout << f.at(n) << endl; } }
replace
17
19
17
19
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; int main() { ll n; cin >> n; for (int i = 1; i <= n; ++i) { ll ans = 0; for (int x = 1; x * x <= i; ++x) { for (int y = 1; y * y <= i; ++y) { for (int z = 1; z * z <= i; ++z) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) ans++; } } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; int main() { ll n; cin >> n; for (int i = 1; i <= n; ++i) { ll ans = 0; for (int x = 1; x * x <= i; ++x) { for (int y = x; y * y <= i; ++y) { for (int z = y; z * z <= i; ++z) { if (x * x + y * y + z * z + x * y + y * z + z * x == i) { if (x == y && z == y) { ans++; } else if (x != y && z != y && x != z) { ans += 6; } else { ans += 3; } } } } } cout << ans << endl; } return 0; }
replace
13
17
13
24
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n + 1, 0); for (int i = 1; i <= 100; ++i) { for (int j = 1; j <= 100; ++j) { for (int k = 1; k <= 100; ++k) { int tmp = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i; if (n <= 10001) ++vec[tmp]; } } } for (int i = 0; i < n; ++i) cout << vec[i + 1] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n + 1, 0); for (int i = 1; i <= 100; ++i) { for (int j = 1; j <= 100; ++j) { for (int k = 1; k <= 100; ++k) { int tmp = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i; if (tmp <= 10000) ++vec[tmp]; } } } for (int i = 0; i < n; ++i) cout << vec[i + 1] << "\n"; return 0; }
replace
14
15
14
15
-11
p02608
C++
Runtime Error
#include <iostream> using namespace std; int main() { int N; cin >> N; int ans[10001]; for (int i = 0; i < 10100; i++) { ans[i] = 0; } int v; for (int x = 1; x <= 101; x++) { for (int y = 1; y <= 101; y++) { for (int z = 1; z <= 101; z++) { v = x * x + y * y + z * z + x * y + y * z + z * x; if (v < 10100) { ans[v] += 1; } } } } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } }
#include <iostream> using namespace std; int main() { int N; cin >> N; int ans[10100]; for (int i = 0; i < 10100; i++) { ans[i] = 0; } int v; for (int x = 1; x <= 101; x++) { for (int y = 1; y <= 101; y++) { for (int z = 1; z <= 101; z++) { v = x * x + y * y + z * z + x * y + y * z + z * x; if (v < 10100) { ans[v] += 1; } } } } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } }
replace
8
9
8
9
-6
*** stack smashing detected ***: terminated
p02608
C++
Runtime Error
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define repi(i, x) \ for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #define mp make_pair #define pb push_back #define solve(a) ((a) ? "Yes" : "No") typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<int, int> Pi; typedef vector<Pi> VPi; typedef vector<long long> V; typedef vector<V> VV; typedef pair<long long, long long> P; typedef vector<P> VP; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INFLL = 1LL << 60; const int INF = 1 << 30; const double PI = acos(-1); int main() { int n; cin >> n; Vi ans(n + 2, 0); for (int x = 1; x <= sqrt(n); x++) { for (int y = 1; y <= sqrt(n); y++) { for (int z = 1; z <= sqrt(n); z++) { ans[x * x + y * y + z * z + z * y + y * x + z * x]++; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } // cout << ans << endl; }
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define repi(i, x) \ for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #define mp make_pair #define pb push_back #define solve(a) ((a) ? "Yes" : "No") typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<int, int> Pi; typedef vector<Pi> VPi; typedef vector<long long> V; typedef vector<V> VV; typedef pair<long long, long long> P; typedef vector<P> VP; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INFLL = 1LL << 60; const int INF = 1 << 30; const double PI = acos(-1); int main() { int n; cin >> n; Vi ans(n + 2, 0); for (int x = 1; x <= sqrt(n); x++) { for (int y = 1; y <= sqrt(n); y++) { for (int z = 1; z <= sqrt(n); z++) { if (x * x + y * y + z * z + z * y + y * x + z * x > n) { continue; } ans[x * x + y * y + z * z + z * y + y * x + z * x]++; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } // cout << ans << endl; }
insert
47
47
47
50
0
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int n, ans[10001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i * i <= n; i++) for (int j = 1; j * j <= n; j++) for (int k = 1; k * k <= n; k++) ans[i * i + j * j + k * k + i * j + j * k + i * k]++; for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int n, ans[10001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i * i <= n; i++) for (int j = 1; j * j <= n; j++) for (int k = 1; k * k <= n; k++) { int val = i * i + j * j + k * k + i * j + j * k + i * k; if (val <= n) ans[val]++; } for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; return 0; }
replace
11
13
11
16
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z; int n; cin >> n; for (int i = 1; i <= n; i++) { int counter = 0; for (x = 1; x < 100; x++) { for (y = x; y < 100; y++) { for (z = y; z < 100; z++) { if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y && y == z) counter = counter + 1; else if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y && y != z) counter = counter + 3; else if (i == x * x + y * y + z * z + x * y + y * z + z * x && x != y && y == z) counter = counter + 3; else if (i == x * x + y * y + z * z + x * y + y * z + z * x) counter = counter + 6; } } } cout << counter << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z; int n; cin >> n; for (int i = 1; i <= n; i++) { int counter = 0; for (x = 1; x <= 41; x++) { for (y = x; y < 100; y++) { for (z = y; z < 100; z++) { if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y && y == z) counter = counter + 1; else if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y && y != z) counter = counter + 3; else if (i == x * x + y * y + z * z + x * y + y * z + z * x && x != y && y == z) counter = counter + 3; else if (i == x * x + y * y + z * z + x * y + y * z + z * x) counter = counter + 6; } } } cout << counter << endl; } }
replace
10
11
10
11
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; // f(n)の個数を調べる for (int i = 1; i <= n; i++) { int count = 0; // x, y, z全探索してnと合致しているか調べる for (int j = 1; j <= i; j++) { for (int k = 1; k <= i; k++) { for (int l = 1; l <= i; l++) { int a = j * j + k * k + l * l + j * k + k * l + l * j; if (a == i) { // cout << a << n << j << k << l << endl; count++; } else if (a > i) break; } } } cout << count << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; // f(n)の個数を調べる for (int i = 1; i <= n; i++) { int count = 0; // x, y, z全探索してnと合致しているか調べる for (int j = 1; j <= 105; j++) { for (int k = 1; k <= 105; k++) { for (int l = 1; l <= 105; l++) { int a = j * j + k * k + l * l + j * k + k * l + l * j; if (a == i) { // cout << a << n << j << k << l << endl; count++; } else if (a > i) break; } } } cout << count << endl; } }
replace
11
14
11
14
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<long long> vll; typedef vector<pair<int, int>> vpi; typedef vector<pair<long long, long long>> vpl; typedef pair<int, int> pii; typedef pair<long long, long long> pll; #define INF (int)(1e9) #define MAXX 1.1529215e+18 #define inf 999999 #define EPS (1e-7) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define FOR(i, k, n) for (int i = (k); i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define RALL(a) a.begin(), a.end(), greater<int>() #define ROT(a) a.begin(), a.begin() + 1, a.end() #define RROT(a) a.begin(), a.end() - 1, a.end() #define PB push_back #define MP make_pair #define PI acos(-1.0) #define sz(a) a.size() const ll MOD = 1e9 + 7; const int MAX = 10000000; template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } // cout << 'H' << endl; /*--------------------------------------------*/ int main() { // cout << fixed << setprecision(10) cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int tmp = x * x + y * y + z * z + x * y + y * z + z * x; a[--tmp]++; } } } rep(i, N) { cout << a[i] << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<long long> vll; typedef vector<pair<int, int>> vpi; typedef vector<pair<long long, long long>> vpl; typedef pair<int, int> pii; typedef pair<long long, long long> pll; #define INF (int)(1e9) #define MAXX 1.1529215e+18 #define inf 999999 #define EPS (1e-7) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define FOR(i, k, n) for (int i = (k); i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define RALL(a) a.begin(), a.end(), greater<int>() #define ROT(a) a.begin(), a.begin() + 1, a.end() #define RROT(a) a.begin(), a.end() - 1, a.end() #define PB push_back #define MP make_pair #define PI acos(-1.0) #define sz(a) a.size() const ll MOD = 1e9 + 7; const int MAX = 10000000; template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } // cout << 'H' << endl; /*--------------------------------------------*/ int main() { // cout << fixed << setprecision(10) cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int tmp = x * x + y * y + z * z + x * y + y * z + z * x; if (tmp <= N) { a[--tmp]++; } } } } rep(i, N) { cout << a[i] << endl; } }
replace
61
62
61
64
-11
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define mp make_pair #define S second #define F first ll mod = 1e9 + 7; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define input_from_file freopen("input.txt", "r", stdin); using namespace std::chrono; int main() { // input_from_file fastIO ll n; cin >> n; vector<ll> vec(n + 1, 0); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= n; k++) { ll x = i * i + j * j + k * k + i * j + j * k + k * i; if (x > n) continue; vec[x]++; } } } for (int i = 1; i <= n; i++) cout << vec[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define mp make_pair #define S second #define F first ll mod = 1e9 + 7; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define input_from_file freopen("input.txt", "r", stdin); using namespace std::chrono; int main() { // input_from_file fastIO ll n; cin >> n; vector<ll> vec(n + 1, 0); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= n; k++) { ll x = i * i + j * j + k * k + i * j + j * k + k * i; if (x > n) break; vec[x]++; } } } for (int i = 1; i <= n; i++) cout << vec[i] << endl; return 0; }
replace
24
25
24
25
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using vi = vector<int>; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; for (int x = 1; x <= n; ++x) { int cnt = 0; for (int i = 1; i <= x; ++i) { for (int j = 1; j <= x; ++j) { if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x) break; for (int k = 1; k <= x; ++k) { if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x) break; if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x) ++cnt; } } } cout << cnt << "\n"; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using vi = vector<int>; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; for (int x = 1; x <= n; ++x) { int cnt = 0; for (int i = 1; i <= x; ++i) { if (((i * i) + 1 + 1 + i + 1 + i) > x) break; for (int j = 1; j <= x; ++j) { if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x) break; for (int k = 1; k <= x; ++k) { if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x) break; if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x) ++cnt; } } } cout << cnt << "\n"; } return 0; }
insert
16
16
16
18
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, x, y, z = 0; cin >> a; if (a <= 5) { for (int i = 0; i < a; i++) { cout << 0 << endl; } } else { for (int i = 0; i < 5; i++) { cout << 0 << endl; } for (int i = 6; i <= a; i++) { c = 96; for (x = 1; x <= c; x++) { for (y = 1; y <= x; y++) { for (z = 1; z <= y; z++) { if (x * x + y * y + z * z + x * y + y * z + x * z == i) { if (x == y && y == z) { e++; } else if (x != y && y != z) { e += 6; } else { e += 3; } } } } } cout << e << endl; e = 0; } } }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, x, y, z = 0; cin >> a; if (a <= 5) { for (int i = 0; i < a; i++) { cout << 0 << endl; } } else { for (int i = 0; i < 5; i++) { cout << 0 << endl; } for (int i = 6; i <= a; i++) { c = sqrt(i); for (x = 1; x <= c; x++) { for (y = 1; y <= x; y++) { for (z = 1; z <= y; z++) { if (x * x + y * y + z * z + x * y + y * z + x * z == i) { if (x == y && y == z) { e++; } else if (x != y && y != z) { e += 6; } else { e += 3; } } } } } cout << e << endl; e = 0; } } }
replace
15
16
15
16
TLE
p02608
C++
Runtime Error
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; while (scanf("%d", &n) != EOF) { int i, j, k; int q; int f[10001]; memset(f, 0, sizeof(f)); q = sqrt(n); for (i = 1; i <= q; i++) { for (j = 1; j <= q; j++) { for (k = 1; k <= q; k++) { int d = i * i + j * j + k * k + i * j + j * k + i * k; f[d]++; } } } for (i = 1; i <= n; i++) { printf("%d\n", f[i]); } printf("\n"); } return (0); }
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; while (scanf("%d", &n) != EOF) { int i, j, k; int q; int f[10001]; memset(f, 0, sizeof(f)); q = sqrt(n); for (i = 1; i <= q; i++) { for (j = 1; j <= q; j++) { for (k = 1; k <= q; k++) { int d = i * i + j * j + k * k + i * j + j * k + i * k; if (d <= 10000) { f[d]++; } } } } for (i = 1; i <= n; i++) { printf("%d\n", f[i]); } printf("\n"); } return (0); }
replace
17
18
17
20
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int i, N, x, y, z, t; cin >> N; vector<int> a(N); // vector<int> b(M); // for (i = 1; i <= N; i++){ for (i = 1; i <= N; i++) { a[i] = 0; } for (x = 1; x <= N; x++) { for (y = 1; y <= N; y++) { for (z = 1; z <= N; z++) { t = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + x * z; if (t <= N) { a[t] += 1; } } } } for (i = 1; i <= N; i++) { cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int i, N, x, y, z, t; cin >> N; vector<int> a(N); // vector<int> b(M); // for (i = 1; i <= N; i++){ for (i = 1; i <= N; i++) { a[i] = 0; } for (x = 1; x <= sqrt(N); x++) { for (y = 1; y <= sqrt(N); y++) { for (z = 1; z <= sqrt(N); z++) { t = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + x * z; if (t <= N) { a[t] += 1; } } } } for (i = 1; i <= N; i++) { cout << a[i] << endl; } return 0; }
replace
13
16
13
16
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // std::の省略のため using ll = long long; int main() { ll n, a; int x, y, z; cin >> n; vector<int> f(n); int i = 0; while (i < n) { f[i] = 0; for (x = 1; x <= sqrt(i + 1); x++) { for (y = 1; y <= sqrt(i + 1); y++) { for (z = 1; z <= sqrt(i + 1); z++) { a = x * x + y * y + z * z + x * y + y * z + z * x; if (a == i + 1) f[i]++; } } } cout << f[i] << endl; i++; } return 0; }
#include <bits/stdc++.h> using namespace std; // std::の省略のため using ll = long long; int main() { ll n, a; int x, y, z; cin >> n; vector<int> f(n); int i = 0; while (i < n) { f[i] = 0; for (x = 1; x <= sqrt(i + 1); x++) { for (y = 1; y <= sqrt(i + 1); y++) { for (z = 1; z <= sqrt(i + 1); z++) { a = x * x + y * y + z * z + x * y + y * z + z * x; if (a == i + 1) f[i]++; if (a > i + 1) break; } } } cout << f[i] << endl; i++; } return 0; }
insert
21
21
21
23
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(void) { int n; cin >> n; for (int i = 1; i <= n; i++) { ll ans = 0; for (int x = 1; x * x < i; x++) { for (int y = 1; y * y < i; y++) { int d = 4 * i - 3 * x * x - 3 * y * y - 2 * x * y; for (int j = 0; j * j <= d; j++) { if (j * j == d) { int z = (-1 * (x + y) + j); if (z < 1) continue; if (z % 2 == 1) continue; else { z /= 2; if (x * x + y * y + z * z + x * y + y * z + z * x == i) { ans++; // cout << x << ", " << y << ", " << z << endl; } } } } } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(void) { int n; cin >> n; for (int i = 1; i <= n; i++) { ll ans = 0; for (int x = 1; x * x < i; x++) { for (int y = 1; y * y < i; y++) { int d = 4 * i - 3 * x * x - 3 * y * y - 2 * x * y; if (d < 0) continue; int z = (-1 * (x + y) + sqrt(d)); if (z < 1) continue; else { z /= 2; if (x * x + y * y + z * z + x * y + y * z + z * x == i) { ans++; // cout << x << ", " << y << ", " << z << endl; } } } } cout << ans << endl; } return 0; }
replace
12
26
12
22
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int N = 5e4 + 10; int n, ans[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int x = 1; x * x <= n; x++) { for (int y = 1; y * y <= n; y++) { for (int z = 1; z * z <= n; z++) { int f = 0; f += x * x + y * y + z * z; f += x * y + y * z + z * x; ans[f] += 1; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, ans[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int x = 1; x * x <= n; x++) { for (int y = 1; y * y <= n; y++) { for (int z = 1; z * z <= n; z++) { int f = 0; f += x * x + y * y + z * z; f += x * y + y * z + z * x; ans[f] += 1; } } } for (int i = 1; i <= n; i++) { cout << ans[i] << '\n'; } return 0; }
replace
2
3
2
3
0
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long f(long x, long y, long z) { return pow(x + y + z, 2) - x * y - y * z - z * x; } int main() { long N; cin >> N; for (int i = 1; i <= N; i++) { long cnt = 0; long max = sqrt(i); for (long x = 1; x <= max; x++) { for (long y = 1; y <= max; y++) { for (long z = 1; z <= max; z++) { if (f(x, y, z) == i) cnt++; } } } cout << cnt << endl; } }
#include <bits/stdc++.h> using namespace std; long f(long x, long y, long z) { return pow(x + y + z, 2) - x * y - y * z - z * x; } int main() { long N; cin >> N; for (int i = 1; i <= N; i++) { long cnt = 0; long max = sqrt(i); for (long x = 1; x <= max; x++) { for (long y = 1; y <= x; y++) { for (long z = 1; z <= y; z++) { if (f(x, y, z) == i) { if (x == y) { if (y == z) { cnt++; } else { cnt = cnt + 3; } } else if (y == z) { if (z == x) { cnt++; } else { cnt = cnt + 3; } } else if (z == x) { if (x == y) { cnt++; } else { cnt = cnt + 3; } } else { cnt = cnt + 6; } } } } } cout << cnt << endl; } }
replace
15
19
15
40
TLE
p02608
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[200000005]; char s[100][8]; int main() { ll n, m, k, i, j, l, ans = 0, K, x = 1, y = 1, r, d, z, flag = 1; scanf("%lld", &n); for (x = 1; x <= n; x++) { for (y = 1; y <= n; y++) { for (z = 1; z <= n; z++) { a[x * x + y * y + z * z + x * y + y * z + z * x]++; if (x * x + y * y + z * z + x * y + y * z + z * x > n) { flag = 0; break; } } // if(flag==0)break; } // if(flag==0)break; } for (x = 1; x <= n; x++) printf("%lld\n", a[x]); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[200000005]; char s[100][8]; int main() { ll n, m, k, i, j, l, ans = 0, K, x = 1, y = 1, r, d, z, flag = 1; scanf("%lld", &n); for (x = 1; x * x <= n; x++) { for (y = 1; y * y <= n; y++) { for (z = 1; z * z <= n; z++) { a[x * x + y * y + z * z + x * y + y * z + z * x]++; if (x * x + y * y + z * z + x * y + y * z + z * x > n) { flag = 0; break; } } // if(flag==0)break; } // if(flag==0)break; } for (x = 1; x <= n; x++) printf("%lld\n", a[x]); return 0; }
replace
8
11
8
11
TLE
p02608
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; ll inf = 1000000007; int main(void) { ll n; cin >> n; ll count = 0; for (int i = 1; i <= n; i++) { count = 0; for (int x = 1; x <= sqrt(2 * i) + 1; x++) { for (int y = 1; y <= sqrt(2 * i) + 1; y++) { for (int z = 1; z <= sqrt(2 * i) + 1; z++) { if ((x + y) * (x + y) + (x + z) * (x + z) + (y + z) * (y + z) == 2 * i) { count++; } } } } cout << count << endl; } }
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; ll inf = 1000000007; int main(void) { ll n; cin >> n; ll count = 0; for (int i = 1; i <= n; i++) { count = 0; for (int x = 1; x <= sqrt(2 * i) + 1; x++) { for (int y = 1; y <= sqrt(2 * i) + 1; y++) { if (i - (x * x + x * y + y * y) < 2) { continue; } for (int z = 1; z * z + x * z + y * z <= i - (x * x + y * y + x * y); z++) { if ((x + y) * (x + y) + (x + z) * (x + z) + (y + z) * (y + z) == 2 * i) { count++; } } } } cout << count << endl; } }
replace
22
23
22
27
TLE
p02608
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int n; cin >> n; vector<int> ans(1001, 0); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int m = x * x + y * y + z * z + x * y + y * z + z * x; if (m <= n) ans.at(m)++; } } } for (int i = 1; i <= n; i++) cout << ans.at(i) << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int n; cin >> n; vector<int> ans(10001, 0); for (int x = 1; x <= 100; x++) { for (int y = 1; y <= 100; y++) { for (int z = 1; z <= 100; z++) { int m = x * x + y * y + z * z + x * y + y * z + z * x; if (m <= n) ans.at(m)++; } } } for (int i = 1; i <= n; i++) cout << ans.at(i) << endl; }
replace
8
9
8
9
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long using namespace std; int n, b[200009], num = 0; ll tmp = 0, c[200009], d[200009], tmp1 = 0; char a[200009]; ll pow1(ll a, int n, ll m) { ll ans = 1; while (n) { if (n & 1) ans = ans * a % m; a = a * a % m; n >>= 1; } return ans; } void solve(int x) { // cout<<x<<endl; int num = 1; while (x) { int tmp = x, num1 = 0; while (tmp) { num1 += tmp % 2; tmp /= 2; } x %= num1; num++; } printf("%d\n", num); } int main() { scanf("%d%s", &n, a); for (int i = 0; i < n; i++) b[n - i - 1] = a[i] - '0'; for (int i = 0; i < n; i++) num += b[i]; for (int i = 0; i < n; i++) { c[i] = pow1(2, i, num - 1); d[i] = pow1(2, i, num + 1); if (b[i]) tmp += c[i], tmp1 += d[i]; } for (int i = n - 1; i >= 0; i--) { if (b[i]) { if (num - 1 != 0) solve((tmp - c[i]) % (num - 1)); else printf("0\n"); } else solve((tmp1 + d[i]) % (num + 1)); } return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int n, b[200009], num = 0; ll tmp = 0, c[200009], d[200009], tmp1 = 0; char a[200009]; ll pow1(ll a, int n, ll m) { ll ans = 1; while (n) { if (n & 1) ans = ans * a % m; a = a * a % m; n >>= 1; } return ans; } void solve(int x) { // cout<<x<<endl; int num = 1; while (x) { int tmp = x, num1 = 0; while (tmp) { num1 += tmp % 2; tmp /= 2; } x %= num1; num++; } printf("%d\n", num); } int main() { scanf("%d%s", &n, a); for (int i = 0; i < n; i++) b[n - i - 1] = a[i] - '0'; for (int i = 0; i < n; i++) num += b[i]; for (int i = 0; i < n; i++) { if (num - 1 > 0) c[i] = pow1(2, i, num - 1); d[i] = pow1(2, i, num + 1); if (b[i]) tmp += c[i], tmp1 += d[i]; } for (int i = n - 1; i >= 0; i--) { if (b[i]) { if (num - 1 != 0) solve((tmp - c[i]) % (num - 1)); else printf("0\n"); } else solve((tmp1 + d[i]) % (num + 1)); } return 0; }
replace
37
38
37
39
0
p02609
C++
Runtime Error
#include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int popcount(int x) { vector<int> a; while (x != 0) { a.emplace_back(x % 2); x /= 2; } int res = 0; for (auto p : a) { if (p == 1) { res++; } } return res; } int f(int x) { if (x == 0) { return 1; } int pcnt = popcount(x); return f(x % pcnt) + 1; } int main() { int N; string S; cin >> N >> S; vector<int> X(N); for (int i = 0; i < N; i++) { X[i] = (int)S[i] - (int)'0'; } long long one = 0; for (int i = 0; i < N; i++) { one += X[i]; } vector<int> m(2, 0); for (int i = 0; i < N; i++) { m[0] = (m[0] * 2) % (one + 1); m[0] += X[i]; } if (one > 1) { for (int i = 0; i < N; i++) { m[1] = (m[1] * 2) % (one - 1); m[1] += X[i]; } } // cout<<"m:"<<m[0]<<" "<<m[1]<<endl; vector<int> ans(N); int k0, k1; k0 = 1; k1 = 1; for (int i = N - 1; i >= 0; i--) { if (X[i] == 0) { ans[i] = f((m[0] + k0) % (one + 1)); } else { if (one == 1) { ans[i] = 0; } else { ans[i] = f((m[1] - k1 + (one - 1)) % (one - 1)); } } k0 = k0 * 2 % (one + 1); if (one != 0) { k1 = k1 * 2 % (one - 1); } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } return 0; }
#include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int popcount(int x) { vector<int> a; while (x != 0) { a.emplace_back(x % 2); x /= 2; } int res = 0; for (auto p : a) { if (p == 1) { res++; } } return res; } int f(int x) { if (x == 0) { return 1; } int pcnt = popcount(x); return f(x % pcnt) + 1; } int main() { int N; string S; cin >> N >> S; vector<int> X(N); for (int i = 0; i < N; i++) { X[i] = (int)S[i] - (int)'0'; } long long one = 0; for (int i = 0; i < N; i++) { one += X[i]; } vector<int> m(2, 0); for (int i = 0; i < N; i++) { m[0] = (m[0] * 2) % (one + 1); m[0] += X[i]; } if (one > 1) { for (int i = 0; i < N; i++) { m[1] = (m[1] * 2) % (one - 1); m[1] += X[i]; } } // cout<<"m:"<<m[0]<<" "<<m[1]<<endl; vector<int> ans(N); int k0, k1; k0 = 1; k1 = 1; for (int i = N - 1; i >= 0; i--) { if (X[i] == 0) { ans[i] = f((m[0] + k0) % (one + 1)); } else { if (one == 1) { ans[i] = 0; } else { ans[i] = f((m[1] - k1 + (one - 1)) % (one - 1)); } } k0 = k0 * 2 % (one + 1); if (one > 1) { k1 = k1 * 2 % (one - 1); } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } return 0; }
replace
76
77
76
77
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const ll MOD = 1e9 + 7; ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { int N; cin >> N; string X; cin >> X; vector<ll> f(N); ll cnt = 0; for (int i = 0; i < N; i++) { if (X[i] == '1') cnt++; } // choose 0 or 1 ll r0 = 0, r1 = 0; for (ll i = 0; i < N; i++) { if (X[i] == '1') { r0 = (r0 + modpow(2, N - i - 1, cnt + 1)) % (cnt + 1); if (cnt > 1) r1 = (r1 + modpow(2, N - i - 1, cnt - 1)) % (cnt - 1); } } for (ll i = 0; i < N; i++) { if (X[i] == '0') { ll val = (r0 + modpow(2, N - i - 1, cnt + 1)) % (cnt + 1); if (val < 0) val += (cnt + 1); int res = 1; while (val != 0) { val %= __builtin_popcountll(val); res++; } f[i] = res; } else { ll val = (r1 - modpow(2, N - i - 1, cnt - 1)) % (cnt - 1); if (val < 0) val += (cnt - 1); int res = 1; while (val != 0) { val %= __builtin_popcountll(val); res++; } f[i] = res; } } for (int i = 0; i < N; i++) { cout << f[i] << endl; } return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const ll MOD = 1e9 + 7; ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { int N; cin >> N; string X; cin >> X; vector<ll> f(N); ll cnt = 0; for (int i = 0; i < N; i++) { if (X[i] == '1') cnt++; } // choose 0 or 1 ll r0 = 0, r1 = 0; for (ll i = 0; i < N; i++) { if (X[i] == '1') { r0 = (r0 + modpow(2, N - i - 1, cnt + 1)) % (cnt + 1); if (cnt > 1) r1 = (r1 + modpow(2, N - i - 1, cnt - 1)) % (cnt - 1); } } for (ll i = 0; i < N; i++) { if (X[i] == '0') { ll val = (r0 + modpow(2, N - i - 1, cnt + 1)) % (cnt + 1); if (val < 0) val += (cnt + 1); int res = 1; while (val != 0) { val %= __builtin_popcountll(val); res++; } f[i] = res; } else { if (cnt == 1) { f[i] = 0; continue; } ll val = (r1 - modpow(2, N - i - 1, cnt - 1)) % (cnt - 1); if (val < 0) val += (cnt - 1); int res = 1; while (val != 0) { val %= __builtin_popcountll(val); res++; } f[i] = res; } } for (int i = 0; i < N; i++) { cout << f[i] << endl; } return 0; }
insert
58
58
58
62
0
p02609
C++
Runtime Error
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef pair<int, int> P; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int memo[200005]; int calc(int x) { if (x == 0) return 0; if (memo[x] != -1) return memo[x]; int p = 0; int y = x; while (y > 0) { p += y % 2; y /= 2; } if (p == 0) return 0; return calc(x % p) + 1; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; memset(memo, -1, sizeof(memo)); memo[0] = 0; for (int i = 1; i < 200005; ++i) { memo[i] = calc(i); } int cnt = 0; rep(i, n) { if (s[i] == '1') ++cnt; } int lCnt = cnt - 1; if (cnt == 0) lCnt = 0; int uCnt = cnt + 1; int lNum = 0, uNum = 0; rep(i, n) { lNum = (lNum * 2 + (s[i] - '0')) % lCnt; uNum = (uNum * 2 + (s[i] - '0')) % uCnt; } int lTwo = 1, uTwo = 1; vector<int> ans(n, 0); for (int i = n - 1; i >= 0; --i) { int num = 0; if (s[i] == '0') { num = (uNum + uTwo) % uCnt; ans[i] = memo[num] + 1; } else { if (cnt != 1) { num = (lNum + lCnt - lTwo) % lCnt; ans[i] = memo[num] + 1; } else { ans[i] = 0; } } lTwo = (lTwo * 2) % lCnt; uTwo = (uTwo * 2) % uCnt; } rep(i, n) cout << ans[i] << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef pair<int, int> P; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int memo[200005]; int calc(int x) { if (x == 0) return 0; if (memo[x] != -1) return memo[x]; int p = 0; int y = x; while (y > 0) { p += y % 2; y /= 2; } if (p == 0) return 0; return calc(x % p) + 1; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; memset(memo, -1, sizeof(memo)); memo[0] = 0; for (int i = 1; i < 200005; ++i) { memo[i] = calc(i); } int cnt = 0; rep(i, n) { if (s[i] == '1') ++cnt; } int lCnt = cnt - 1; chmax(lCnt, 1); int uCnt = cnt + 1; int lNum = 0, uNum = 0; rep(i, n) { lNum = (lNum * 2 + (s[i] - '0')) % lCnt; uNum = (uNum * 2 + (s[i] - '0')) % uCnt; } int lTwo = 1, uTwo = 1; vector<int> ans(n, 0); for (int i = n - 1; i >= 0; --i) { int num = 0; if (s[i] == '0') { num = (uNum + uTwo) % uCnt; ans[i] = memo[num] + 1; } else { if (cnt != 1) { num = (lNum + lCnt - lTwo) % lCnt; ans[i] = memo[num] + 1; } else { ans[i] = 0; } } lTwo = (lTwo * 2) % lCnt; uTwo = (uTwo * 2) % uCnt; } rep(i, n) cout << ans[i] << endl; return 0; }
replace
55
57
55
56
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main() { int N; cin >> N; string X; cin >> X; ll t = count(X.begin(), X.end(), '1'); vector<ll> powl(N + 1, 1), pow(N + 1, 1), powu(N + 1, 1); for (int i = 1; i <= N; i++) { if (t > 1) powl[i] = powl[i - 1] * 2 % (t - 1); pow[i] = pow[i - 1] * 2 % (t); powu[i] = powu[i - 1] * 2 % (t + 1); } ll allu = 0, all = 0, alll = 0; for (int i = 0; i <= N - 1; i++) { if (X[N - 1 - i] == '1') { alll += powl[i]; all += pow[i]; allu += powu[i]; if (t > 1) alll %= t - 1; all %= t; allu %= t + 1; } } for (int i = 0; i <= N - 1; i++) { ll cnt = 1; ll now; if (X[i] == '0') { now = (allu + powu[N - 1 - i]) % (t + 1); } else { if (t == 1) { cout << 0 << endl; continue; } now = (alll + (t - 1) - powl[N - 1 - i]) % (t - 1); } while (now > 0) { now %= __builtin_popcount(now); cnt++; } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double int main() { int N; cin >> N; string X; cin >> X; ll t = count(X.begin(), X.end(), '1'); if (t == 0) { for (int i = 0; i < N; i++) cout << 1 << endl; return 0; } vector<ll> powl(N + 1, 1), pow(N + 1, 1), powu(N + 1, 1); for (int i = 1; i <= N; i++) { if (t > 1) powl[i] = powl[i - 1] * 2 % (t - 1); pow[i] = pow[i - 1] * 2 % (t); powu[i] = powu[i - 1] * 2 % (t + 1); } ll allu = 0, all = 0, alll = 0; for (int i = 0; i <= N - 1; i++) { if (X[N - 1 - i] == '1') { alll += powl[i]; all += pow[i]; allu += powu[i]; if (t > 1) alll %= t - 1; all %= t; allu %= t + 1; } } for (int i = 0; i <= N - 1; i++) { ll cnt = 1; ll now; if (X[i] == '0') { now = (allu + powu[N - 1 - i]) % (t + 1); } else { if (t == 1) { cout << 0 << endl; continue; } now = (alll + (t - 1) - powl[N - 1 - i]) % (t - 1); } while (now > 0) { now %= __builtin_popcount(now); cnt++; } cout << cnt << endl; } return 0; }
insert
11
11
11
16
0
p02609
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef unsigned long long ull; #define st first #define sd second #define mkp make_pair #define pb push_back void wenjian() { freopen("concatenation.in", "r", stdin); freopen("concatenation.out", "w", stdout); } void tempwj() { freopen("hash.in", "r", stdin); freopen("hash.out", "w", stdout); } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll qpow(ll a, ll b, ll mod) { a %= mod; ll ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } struct cmp { bool operator()(const pii &a, const pii &b) { return a.second > b.second; } }; int lb(int x) { return x & -x; } const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; const ll mod = 2147483648; const int maxn = 4e5 + 5; vector<int> vv; int s[maxn]; ll t[maxn]; char a[maxn]; int main() { for (int i = 1; i <= 2e5; i++) { int ans = 0; int x = i; while (x) { int temp = 0; int t = x; while (t) { if (t & 1) temp++; t >>= 1; } x %= temp; ans++; } s[i] = ans; } int n; scanf("%d%s", &n, a + 1); int s1 = 0; for (int i = 1; i <= n; i++) { if (a[i] == '1') s1++; } t[s1] = 0; // intf("11111111\n"); for (int i = 1; i <= n; i++) { // printf("%d\n",i); for (int k = max(0, s1 - 1); k <= s1 + 1; k++) { // printf("%d\n",k); if (k > 0) { t[k] = (t[k] * 2 % k + (a[i] - '0')) % k; } } } for (int i = 1; i <= n; i++) { int k = n - i; int y; if (a[i] == '1') { y = s1 - 1; ll ss = qpow(2, k, y); printf("%d\n", s[((t[y] - ss) % y + y) % y] + 1); } else { y = s1 + 1; ll ss = qpow(2, k, y); printf("%d\n", s[(t[y] + ss) % y] + 1); } } }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef unsigned long long ull; #define st first #define sd second #define mkp make_pair #define pb push_back void wenjian() { freopen("concatenation.in", "r", stdin); freopen("concatenation.out", "w", stdout); } void tempwj() { freopen("hash.in", "r", stdin); freopen("hash.out", "w", stdout); } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll qpow(ll a, ll b, ll mod) { a %= mod; ll ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } struct cmp { bool operator()(const pii &a, const pii &b) { return a.second > b.second; } }; int lb(int x) { return x & -x; } const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; const ll mod = 2147483648; const int maxn = 4e5 + 5; vector<int> vv; int s[maxn]; ll t[maxn]; char a[maxn]; int main() { for (int i = 1; i <= 2e5; i++) { int ans = 0; int x = i; while (x) { int temp = 0; int t = x; while (t) { if (t & 1) temp++; t >>= 1; } x %= temp; ans++; } s[i] = ans; } int n; scanf("%d%s", &n, a + 1); int s1 = 0; for (int i = 1; i <= n; i++) { if (a[i] == '1') s1++; } t[s1] = 0; // intf("11111111\n"); for (int i = 1; i <= n; i++) { // printf("%d\n",i); for (int k = max(0, s1 - 1); k <= s1 + 1; k++) { // printf("%d\n",k); if (k > 0) { t[k] = (t[k] * 2 % k + (a[i] - '0')) % k; } } } for (int i = 1; i <= n; i++) { int k = n - i; int y; if (a[i] == '1') { y = s1 - 1; if (y == 0) { printf("0\n"); continue; } ll ss = qpow(2, k, y); printf("%d\n", s[((t[y] - ss) % y + y) % y] + 1); } else { y = s1 + 1; ll ss = qpow(2, k, y); printf("%d\n", s[(t[y] + ss) % y] + 1); } } }
insert
95
95
95
99
0
p02609
C++
Runtime Error
/// #pragma GCC optimize("O3,unroll-loops") /// #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ull unsigned long long #define ld long double #define inf 2000000000 #define infLL 2000000000000000000 #define MAX5 100005 #define MAX6 1000006 #define MAX7 10000007 #define sf(a) scanf("%d", &a) #define sfl(a) scanf("%lld", &a) #define pf(a) printf("%d\n", a) #define pfl(a) printf("%lld\n", a) #define Case(t) printf("Case %d: ", t) #define pii pair<int, int> #define mod 1000000007 #define Mod 998244353 #define PI acos(-1.0) #define eps 1e-9 #define mem(a, b) memset(a, b, sizeof(a)) #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ cerr << '\n'; \ } inline int Set(ll N, ll pos) { return N = N | (1LL << pos); } inline int Reset(ll N, ll pos) { return N = N & ~(1LL << pos); } inline bool Check(ll N, ll pos) { return (bool)(N & (1LL << pos)); } inline bool Equal(ld x, ld y) { return fabs(x - y) < eps; } /// x==y inline bool Greater(ld x, ld y) { return (x - eps) > y; } /// x>y inline bool Lesser(ld x, ld y) { return (x + eps) < y; } /// x<y inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); } inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; } inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; } inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; } inline ll modInverse(ll a) { return modPow(a, mod - 2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } /// Memory Efficient inline ll fast_exp(ll x, ll n, ll m) { ll res = 1; while (n > 0) { if (n % 2 == 1) res = (res * x) % m; x = (x * x) % m; n /= 2; } return res % m; } // int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right // int dy[] = {+1, -1, +0, +0}; // int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move // int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; // int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; ///Knight's Move // int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << " "; err(++it, args...); } inline void Time() { cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; } typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet1; const int N = 200001; ll solve(int x) { int ans = 0; while (x > 0) { int cnt = __builtin_popcount(x); x = x % cnt; ans++; } return ans; } int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); FASTIO; int n; cin >> n; string s; cin >> s; int one = 0; for (int i = 0; i < n; i++) if (s[i] == '1') one++; int sum0 = 0, sum1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') continue; if (one > 0) sum0 = (sum0 + fast_exp(2, n - 1 - i, one - 1)) % (one - 1); sum1 = (sum1 + fast_exp(2, n - 1 - i, one + 1)) % (one + 1); } /// error(sum0, sum1); ll ans; for (int i = 0; i < n; i++) { ll sum = 0; if (s[i] == '1') { sum = sum0; if (one > 1) { sum = (sum - fast_exp(2, n - 1 - i, one - 1)) % (one - 1); if (sum < 0) sum += (one - 1); ans = 1 + solve(sum); } else ans = 0; } else { sum = sum1; sum = (sum + fast_exp(2, n - 1 - i, one + 1)) % (one + 1); ans = 1 + solve(sum); } cout << ans << endl; } /// Time(); return 0; }
/// #pragma GCC optimize("O3,unroll-loops") /// #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ull unsigned long long #define ld long double #define inf 2000000000 #define infLL 2000000000000000000 #define MAX5 100005 #define MAX6 1000006 #define MAX7 10000007 #define sf(a) scanf("%d", &a) #define sfl(a) scanf("%lld", &a) #define pf(a) printf("%d\n", a) #define pfl(a) printf("%lld\n", a) #define Case(t) printf("Case %d: ", t) #define pii pair<int, int> #define mod 1000000007 #define Mod 998244353 #define PI acos(-1.0) #define eps 1e-9 #define mem(a, b) memset(a, b, sizeof(a)) #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ cerr << '\n'; \ } inline int Set(ll N, ll pos) { return N = N | (1LL << pos); } inline int Reset(ll N, ll pos) { return N = N & ~(1LL << pos); } inline bool Check(ll N, ll pos) { return (bool)(N & (1LL << pos)); } inline bool Equal(ld x, ld y) { return fabs(x - y) < eps; } /// x==y inline bool Greater(ld x, ld y) { return (x - eps) > y; } /// x>y inline bool Lesser(ld x, ld y) { return (x + eps) < y; } /// x<y inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); } inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; } inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; } inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; } inline ll modInverse(ll a) { return modPow(a, mod - 2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } /// Memory Efficient inline ll fast_exp(ll x, ll n, ll m) { ll res = 1; while (n > 0) { if (n % 2 == 1) res = (res * x) % m; x = (x * x) % m; n /= 2; } return res % m; } // int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right // int dy[] = {+1, -1, +0, +0}; // int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move // int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; // int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; ///Knight's Move // int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << " "; err(++it, args...); } inline void Time() { cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; } typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet1; const int N = 200001; ll solve(int x) { int ans = 0; while (x > 0) { int cnt = __builtin_popcount(x); x = x % cnt; ans++; } return ans; } int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); FASTIO; int n; cin >> n; string s; cin >> s; int one = 0; for (int i = 0; i < n; i++) if (s[i] == '1') one++; int sum0 = 0, sum1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') continue; if (one > 1) sum0 = (sum0 + fast_exp(2, n - 1 - i, one - 1)) % (one - 1); sum1 = (sum1 + fast_exp(2, n - 1 - i, one + 1)) % (one + 1); } /// error(sum0, sum1); ll ans; for (int i = 0; i < n; i++) { ll sum = 0; if (s[i] == '1') { sum = sum0; if (one > 1) { sum = (sum - fast_exp(2, n - 1 - i, one - 1)) % (one - 1); if (sum < 0) sum += (one - 1); ans = 1 + solve(sum); } else ans = 0; } else { sum = sum1; sum = (sum + fast_exp(2, n - 1 - i, one + 1)) % (one + 1); ans = 1 + solve(sum); } cout << ans << endl; } /// Time(); return 0; }
replace
147
148
147
148
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int popcount(int n) { int r = 0; while (n > 0) { r += n & 1; n >>= 1; } return r; } int popcount(string n) { int r = 0; for (auto c : n) { r += c == '1'; } return r; } int f(int n) { int k = 0; while (n != 0) { n %= popcount(n); k++; } return k; } int pow_mod(int a, int b, int mod) { if (b == 0) return 1 % mod; int k = pow_mod(a, b / 2, mod); k *= k; k %= mod; if (b % 2 == 0) return k; return (k * a) % mod; } int main() { int N; string X; cin >> N >> X; reverse(X.begin(), X.end()); int s = popcount(X); int A = 0, B = 0; for (int i = 0; i < N; i++) { if (X[i] == '1') { A += pow_mod(2, i, s + 1); A %= s + 1; if (s - 1 > 0) { B += pow_mod(2, i, s - 1); B %= s - 1; } } } for (int i = N - 1; i >= 0; i--) { if (X[i] == '1') { if (s - 1 == 0) { cout << 0 << endl; continue; } int b = B; b -= pow_mod(2, i, s - 1); b += s - 1; b %= s - 1; cout << 1 + f(b) << endl; } else { int a = A; a += pow_mod(2, i, s + 1); a %= s + 1; cout << 1 + f(a) << endl; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int popcount(int n) { int r = 0; while (n > 0) { r += n & 1; n >>= 1; } return r; } int popcount(string n) { int r = 0; for (auto c : n) { r += c == '1'; } return r; } int f(int n) { int k = 0; while (n != 0) { n %= popcount(n); k++; } return k; } int pow_mod(int a, int b, int mod) { if (b == 0) return 1 % mod; ll k = pow_mod(a, b / 2, mod); k *= k; k %= mod; if (b % 2 == 0) return k; return (k * a) % mod; } int main() { int N; string X; cin >> N >> X; reverse(X.begin(), X.end()); int s = popcount(X); int A = 0, B = 0; for (int i = 0; i < N; i++) { if (X[i] == '1') { A += pow_mod(2, i, s + 1); A %= s + 1; if (s - 1 > 0) { B += pow_mod(2, i, s - 1); B %= s - 1; } } } for (int i = N - 1; i >= 0; i--) { if (X[i] == '1') { if (s - 1 == 0) { cout << 0 << endl; continue; } int b = B; b -= pow_mod(2, i, s - 1); b += s - 1; b %= s - 1; cout << 1 + f(b) << endl; } else { int a = A; a += pow_mod(2, i, s + 1); a %= s + 1; cout << 1 + f(a) << endl; } } }
replace
29
30
29
30
0
p02609
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; long long Calc(long long P) { if (P == 0) return 0; long long COUNT = 0; long long Q = P; while (Q > 0) { COUNT += Q % 2; Q /= 2; } return Calc(P % COUNT) + 1; } long long Pow(long long A, long long B, long long M) { if (B == 0) return 1 % M; if (B % 2 == 0) { long long C = Pow(A, B / 2, M); return (C * C) % M; } return (A * Pow(A, B - 1, M)) % M; } int main() { long long N; string S; cin >> N >> S; long long X = 0; for (int i = 0; i < N; i++) X += (S[i] - '0'); long long MOD1 = 0, MOD2 = 0, Y = X - 1, Z = X + 1; if (Y != 0) { for (int i = 0; i < N; i++) { MOD1 *= 2; MOD1 += S[i] - '0'; MOD1 %= Y; } } for (int i = 0; i < N; i++) { MOD2 *= 2; MOD2 += S[i] - '0'; MOD2 %= Z; } for (int i = 0; i < N; i++) { if (S[i] == '0') { long long NEXT = (MOD2 + Pow(2, N - 1 - i, Z)) % Z; cout << Calc(NEXT) + 1 << endl; } else { if (Y == 0) cout << 0 << endl; long long NEXT = (MOD1 - Pow(2, N - 1 - i, Y) + Y) % Y; cout << Calc(NEXT) + 1 << endl; } } }
#include "bits/stdc++.h" using namespace std; long long Calc(long long P) { if (P == 0) return 0; long long COUNT = 0; long long Q = P; while (Q > 0) { COUNT += Q % 2; Q /= 2; } return Calc(P % COUNT) + 1; } long long Pow(long long A, long long B, long long M) { if (B == 0) return 1 % M; if (B % 2 == 0) { long long C = Pow(A, B / 2, M); return (C * C) % M; } return (A * Pow(A, B - 1, M)) % M; } int main() { long long N; string S; cin >> N >> S; long long X = 0; for (int i = 0; i < N; i++) X += (S[i] - '0'); long long MOD1 = 0, MOD2 = 0, Y = X - 1, Z = X + 1; if (Y != 0) { for (int i = 0; i < N; i++) { MOD1 *= 2; MOD1 += S[i] - '0'; MOD1 %= Y; } } for (int i = 0; i < N; i++) { MOD2 *= 2; MOD2 += S[i] - '0'; MOD2 %= Z; } for (int i = 0; i < N; i++) { if (S[i] == '0') { long long NEXT = (MOD2 + Pow(2, N - 1 - i, Z)) % Z; cout << Calc(NEXT) + 1 << endl; } else { if (Y == 0) cout << 0 << endl; else { long long NEXT = (MOD1 - Pow(2, N - 1 - i, Y) + Y) % Y; cout << Calc(NEXT) + 1 << endl; } } } }
replace
52
54
52
56
0
p02609
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ld long double #define ull unsigned long long #define ll long long #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using namespace std; // using namespace __gnu_pbds; // typedef tree<int, null_type, less_equal<int>, rb_tree_tag, // tree_order_statistics_node_update> ordered_set; ld eps = (ld)1 / 1e6; ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353; ll sqr(ll a) { return a * a; } ll qb(ll a) { return a * a * a; } ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); } ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; } ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ll md[200010][2]; ll solve(ll x) { if (!x) return 0; bitset<40> bt = x; ll t = bt.count(); return (1 + solve(x % t)); } int main() { fast_io; ll n, i, k0 = 0, n1 = 0, n2 = 0, nw; string a; cin >> n >> a; for (i = 0; i < n; i++) if (a[i] == '1') k0++; md[0][0] = md[0][1] = 1; for (i = 1; i < n; i++) { if (k0 > 1) md[i][0] = (2 * md[i - 1][0]) % (k0 - 1); md[i][1] = (2 * md[i - 1][1]) % (k0 + 1); } for (i = 0; i < n; i++) { if (a[i] == '0') continue; if (k0 > 1) n1 = (n1 + md[n - i - 1][0]) % (k0 - 1); n2 = (n2 + md[n - i - 1][1]) % (k0 + 1); } for (i = 0; i < n; i++) { if (k0 == 1 && a[i] == '1') { cout << "0\n"; continue; } if (a[i] == '0') nw = (n2 + md[n - i - 1][1]) % (k0 + 1); else nw = (n1 - md[n - i - 1][0]) % (k0 - 1); cout << 1 + solve(nw) << '\n'; } return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define ld long double #define ull unsigned long long #define ll long long #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using namespace std; // using namespace __gnu_pbds; // typedef tree<int, null_type, less_equal<int>, rb_tree_tag, // tree_order_statistics_node_update> ordered_set; ld eps = (ld)1 / 1e6; ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353; ll sqr(ll a) { return a * a; } ll qb(ll a) { return a * a * a; } ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); } ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; } ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ll md[200010][2]; ll solve(ll x) { if (!x) return 0; bitset<40> bt = x; ll t = bt.count(); return (1 + solve(x % t)); } int main() { fast_io; ll n, i, k0 = 0, n1 = 0, n2 = 0, nw; string a; cin >> n >> a; for (i = 0; i < n; i++) if (a[i] == '1') k0++; md[0][0] = md[0][1] = 1; for (i = 1; i < n; i++) { if (k0 > 1) md[i][0] = (2 * md[i - 1][0]) % (k0 - 1); md[i][1] = (2 * md[i - 1][1]) % (k0 + 1); } for (i = 0; i < n; i++) { if (a[i] == '0') continue; if (k0 > 1) n1 = (n1 + md[n - i - 1][0]) % (k0 - 1); n2 = (n2 + md[n - i - 1][1]) % (k0 + 1); } for (i = 0; i < n; i++) { if (k0 == 1 && a[i] == '1') { cout << "0\n"; continue; } if (a[i] == '0') nw = (n2 + md[n - i - 1][1]) % (k0 + 1); else nw = (n1 - md[n - i - 1][0] + k0 - 1) % (k0 - 1); cout << 1 + solve(nw) << '\n'; } return 0; }
replace
88
89
88
89
TLE
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define ld long double #define ri register int #define il inline #define mk make_pair #define pb push_back #define fi first #define se second #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define all(x) x.begin(), x.end() #define rep(i, a, b) for (ri i = (a); i <= (b); ++i) #define per(i, a, b) for (ri i = (a); i >= (b); --i) #define ls (x << 1) #define rs (x << 1 | 1) #define mid (l + r >> 1) #define de(x) cout << #x << " = " << x << endl #define dd() cout << "Out Put!\n" const int maxn = 1000010; const double eps = 1e-8, PI = acos(-1.0); const int inf = 0x7f7f7f7f; using namespace std; int a[maxn]; char s[maxn]; il int qpow(int base, int m, int mod) { int res = 1; while (m) { if (m & 1) (res *= base) %= mod; (base *= base) %= mod; m >>= 1ll; } return res % mod; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n >> s; int l = strlen(s) - 1; int sum = 0; rep(i, 0, l) sum += s[i] - '0'; int d = 0, e = 0, f = 0; per(i, l, 0) if (s[i] == '1') { if (sum != 1) d += qpow(2, l - i, sum - 1); f += qpow(2, l - i, sum + 1); } a[0] = 0; rep(i, 1, 200010) { int x = i; int ans = 0; int f = 0; while (x) { int cnt = 0; rep(j, 0, 25) if ((1ll << j) & x) cnt++; if (!f) f = cnt; x = x % cnt; ans++; } a[i] = ans; } rep(i, 0, l) { if (s[i] == '1') { if (sum == 1) cout << 1 << endl; int p = d; p -= qpow(2, l - i, sum - 1); p = (p + sum - 1) % (sum - 1); cout << a[p] + 1 << endl; } else { int p = f; p += qpow(2, l - i, sum + 1); p %= (sum + 1); cout << a[p] + 1 << endl; } } return 0; }
#include <bits/stdc++.h> #define int long long #define ld long double #define ri register int #define il inline #define mk make_pair #define pb push_back #define fi first #define se second #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define all(x) x.begin(), x.end() #define rep(i, a, b) for (ri i = (a); i <= (b); ++i) #define per(i, a, b) for (ri i = (a); i >= (b); --i) #define ls (x << 1) #define rs (x << 1 | 1) #define mid (l + r >> 1) #define de(x) cout << #x << " = " << x << endl #define dd() cout << "Out Put!\n" const int maxn = 1000010; const double eps = 1e-8, PI = acos(-1.0); const int inf = 0x7f7f7f7f; using namespace std; int a[maxn]; char s[maxn]; il int qpow(int base, int m, int mod) { int res = 1; while (m) { if (m & 1) (res *= base) %= mod; (base *= base) %= mod; m >>= 1ll; } return res % mod; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n >> s; int l = strlen(s) - 1; int sum = 0; rep(i, 0, l) sum += s[i] - '0'; int d = 0, e = 0, f = 0; per(i, l, 0) if (s[i] == '1') { if (sum != 1) d += qpow(2, l - i, sum - 1); f += qpow(2, l - i, sum + 1); } a[0] = 0; rep(i, 1, 200010) { int x = i; int ans = 0; int f = 0; while (x) { int cnt = 0; rep(j, 0, 25) if ((1ll << j) & x) cnt++; if (!f) f = cnt; x = x % cnt; ans++; } a[i] = ans; } rep(i, 0, l) { if (s[i] == '1') { if (sum == 1) { cout << 0 << endl; continue; } int p = d; p -= qpow(2, l - i, sum - 1); p = (p + sum - 1) % (sum - 1); cout << a[p] + 1 << endl; } else { int p = f; p += qpow(2, l - i, sum + 1); p %= (sum + 1); cout << a[p] + 1 << endl; } } return 0; }
replace
68
70
68
72
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T, vector<T>, greater<T>> #define dame(a) \ { \ out(a); \ return 0; \ } #define decimal cout << fixed << setprecision(15); #define dupli(a) a.erase(unique(all(a)), a.end()) typedef long long ll; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> PP; typedef tuple<ll, ll, ll, ll> PPP; typedef multiset<ll> S; using vi = vector<ll>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vvvvi = vector<vvvi>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; const ll inf = 1001001001001001001; const ll INF = 1001001001; const ll mod = 1000000007; const double eps = 1e-10; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> void out(T a) { cout << a << '\n'; } template <class T> void outp(T a) { cout << '(' << a.fi << ',' << a.se << ')' << '\n'; } template <class T> void outvp(T v) { rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')'; cout << '\n'; } template <class T> void outvvp(T v) { rep(i, v.size()) outvp(v[i]); } template <class T> void outv(T v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); } template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); } template <class T> void yesno(T b) { if (b) out("yes"); else out("no"); } template <class T> void YesNo(T b) { if (b) out("Yes"); else out("No"); } template <class T> void YESNO(T b) { if (b) out("YES"); else out("NO"); } template <class T> void noyes(T b) { if (b) out("no"); else out("yes"); } template <class T> void NoYes(T b) { if (b) out("No"); else out("Yes"); } template <class T> void NOYES(T b) { if (b) out("NO"); else out("YES"); } void outs(ll a, ll b) { if (a >= inf - 100) out(b); else out(a); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll modpow(ll a, ll b) { ll res = 1; a %= mod; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } ll g(ll a) { return __builtin_popcount(a); } vi dp; ll dfs(int i) { if (dp[i] != -1) return dp[i]; if (i == 0) { dp[i] = 0; return 0; } dp[i] = dfs(i % g(i)) + 1; return dp[i]; } int main() { ll n; cin >> n; string s; cin >> s; dp = vi(n + 1, -1); for (int i = n; i >= 0; i--) dfs(i); ll cnt = 0; rep(i, n) if (s[i] == '1') cnt++; vi ans(n); if (cnt) { ll d = 0; rep(i, n) { d *= 2; d += s[i] - '0'; d %= (cnt - 1); } vi v(n); v[n - 1] = 1; for (int i = n - 2; i >= 0; i--) v[i] = v[i + 1] * 2 % (cnt - 1); rep(i, n) if (s[i] == '1') { if (cnt == 1) ans[i] = 0; else ans[i] = dp[(d + cnt - 1 - v[i]) % (cnt - 1)] + 1; } } if (cnt != n) { ll d = 0; rep(i, n) { d *= 2; d += s[i] - '0'; d %= (cnt + 1); } vi v(n); v[n - 1] = 1; for (int i = n - 2; i >= 0; i--) v[i] = v[i + 1] * 2 % (cnt + 1); rep(i, n) if (s[i] == '0') { ans[i] = dp[(d + v[i]) % (cnt + 1)] + 1; } } for (ll x : ans) out(x); }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T, vector<T>, greater<T>> #define dame(a) \ { \ out(a); \ return 0; \ } #define decimal cout << fixed << setprecision(15); #define dupli(a) a.erase(unique(all(a)), a.end()) typedef long long ll; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> PP; typedef tuple<ll, ll, ll, ll> PPP; typedef multiset<ll> S; using vi = vector<ll>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vvvvi = vector<vvvi>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; const ll inf = 1001001001001001001; const ll INF = 1001001001; const ll mod = 1000000007; const double eps = 1e-10; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> void out(T a) { cout << a << '\n'; } template <class T> void outp(T a) { cout << '(' << a.fi << ',' << a.se << ')' << '\n'; } template <class T> void outvp(T v) { rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')'; cout << '\n'; } template <class T> void outvvp(T v) { rep(i, v.size()) outvp(v[i]); } template <class T> void outv(T v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); } template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); } template <class T> void yesno(T b) { if (b) out("yes"); else out("no"); } template <class T> void YesNo(T b) { if (b) out("Yes"); else out("No"); } template <class T> void YESNO(T b) { if (b) out("YES"); else out("NO"); } template <class T> void noyes(T b) { if (b) out("no"); else out("yes"); } template <class T> void NoYes(T b) { if (b) out("No"); else out("Yes"); } template <class T> void NOYES(T b) { if (b) out("NO"); else out("YES"); } void outs(ll a, ll b) { if (a >= inf - 100) out(b); else out(a); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll modpow(ll a, ll b) { ll res = 1; a %= mod; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } ll g(ll a) { return __builtin_popcount(a); } vi dp; ll dfs(int i) { if (dp[i] != -1) return dp[i]; if (i == 0) { dp[i] = 0; return 0; } dp[i] = dfs(i % g(i)) + 1; return dp[i]; } int main() { ll n; cin >> n; string s; cin >> s; dp = vi(n + 1, -1); for (int i = n; i >= 0; i--) dfs(i); ll cnt = 0; rep(i, n) if (s[i] == '1') cnt++; vi ans(n); if (cnt > 1) { ll d = 0; rep(i, n) { d *= 2; d += s[i] - '0'; d %= (cnt - 1); } vi v(n); v[n - 1] = 1; for (int i = n - 2; i >= 0; i--) v[i] = v[i + 1] * 2 % (cnt - 1); rep(i, n) if (s[i] == '1') { if (cnt == 1) ans[i] = 0; else ans[i] = dp[(d + cnt - 1 - v[i]) % (cnt - 1)] + 1; } } if (cnt != n) { ll d = 0; rep(i, n) { d *= 2; d += s[i] - '0'; d %= (cnt + 1); } vi v(n); v[n - 1] = 1; for (int i = n - 2; i >= 0; i--) v[i] = v[i + 1] * 2 % (cnt + 1); rep(i, n) if (s[i] == '0') { ans[i] = dp[(d + v[i]) % (cnt + 1)] + 1; } } for (ll x : ans) out(x); }
replace
152
153
152
153
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define all(X) (X).begin(), (X).end() #define rall(X) (X).rbegin(), (X).rend() #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define ff first #define ss second #define in(x, a, b) (a <= x && x < b) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) using namespace std; using ll = long long; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; const ll inf = 1000000001, INF = (ll)1e18 + 1; ll power(ll a, ll b, ll P) { ll result = 1; while (b) { if (b % 2) result = (result * a) % P; a = (a * a) % P; b /= 2; } return result; } void solve() { int n; string s; cin >> n >> s; int cnt = 0; for (int i = 0; i < s.length(); i++) if (s[i] == '1') cnt++; vector<vi> values(n, vi(2)); vi sum(2, 0); for (int i = 0; i < n; i++) { values[i][0] = power(2, n - i - 1, cnt - 1); values[i][1] = power(2, n - i - 1, cnt + 1); if (cnt - 1 > 0) sum[0] = (sum[0] + values[i][0] * (s[i] - '0')) % (cnt - 1); sum[1] = (sum[1] + values[i][1] * (s[i] - '0')) % (cnt + 1); } for (int i = 0; i < n; i++) { int m; if (s[i] == '0') { m = (sum[1] + (values[i][1])) % (cnt + 1); } else { if (cnt - 1 > 0) m = (sum[0] - (values[i][0]) + cnt - 1) % (cnt - 1); else { cout << 0 << endl; continue; } } if (m == 0) { cout << 1 << endl; continue; } int ans = 0; while (m) { int mod = __builtin_popcount(m); m %= mod; ans++; } cout << ans + 1 << endl; } } int main() { #define MULTITEST 0 #if MULTITEST CASET { solve(); } #else solve(); #endif return 0; }
#include <bits/stdc++.h> #define all(X) (X).begin(), (X).end() #define rall(X) (X).rbegin(), (X).rend() #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define ff first #define ss second #define in(x, a, b) (a <= x && x < b) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) using namespace std; using ll = long long; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; const ll inf = 1000000001, INF = (ll)1e18 + 1; ll power(ll a, ll b, ll P) { ll result = 1; while (b) { if (b % 2) result = (result * a) % P; a = (a * a) % P; b /= 2; } return result; } void solve() { int n; string s; cin >> n >> s; int cnt = 0; for (int i = 0; i < s.length(); i++) if (s[i] == '1') cnt++; vector<vi> values(n, vi(2)); vi sum(2, 0); for (int i = 0; i < n; i++) { if (cnt - 1 > 0) values[i][0] = power(2, n - i - 1, cnt - 1); values[i][1] = power(2, n - i - 1, cnt + 1); if (cnt - 1 > 0) sum[0] = (sum[0] + values[i][0] * (s[i] - '0')) % (cnt - 1); sum[1] = (sum[1] + values[i][1] * (s[i] - '0')) % (cnt + 1); } for (int i = 0; i < n; i++) { int m; if (s[i] == '0') { m = (sum[1] + (values[i][1])) % (cnt + 1); } else { if (cnt - 1 > 0) m = (sum[0] - (values[i][0]) + cnt - 1) % (cnt - 1); else { cout << 0 << endl; continue; } } if (m == 0) { cout << 1 << endl; continue; } int ans = 0; while (m) { int mod = __builtin_popcount(m); m %= mod; ans++; } cout << ans + 1 << endl; } } int main() { #define MULTITEST 0 #if MULTITEST CASET { solve(); } #else solve(); #endif return 0; }
replace
47
48
47
49
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define sec second #define fir first #define mo 1000000007 #define inf 1e18 #define rep(i, s, n) for (ll i = s; i < n; i = i + 1) #define rrep(i, s, n) for (ll i = s; i >= n; i--) ll mod(ll n) { return (n % (ll)mo + (ll)mo) % (ll)mo; } int main() { ll n; cin >> n; string s; cin >> s; ll c = 0; rep(i, 0, n) { if (s[i] == '1') ++c; } vector<ll> cnt(n + 1, 0); cnt[1] = 1; cnt[2] = 1; rep(i, 3, n + 1) { ll x = __builtin_popcount(i); cnt[i] = cnt[i % x] + 1; } vector<ll> r1(n + 1), r2(n + 1); r1[0] = 1 % (c - 1); r2[0] = 1 % (c + 1); rep(i, 1, n) { r1[i] = (r1[i - 1] * 2) % (c - 1); r2[i] = (r2[i - 1] * 2) % (c + 1); } vector<ll> pr1(n + 1, 0), pr2(n + 1, 0); vector<ll> sr1(n + 2, 0), sr2(n + 2, 0); if (s[0] == '1') pr1[0] = r1[n - 1], pr2[0] = r2[n - 1]; rep(i, 1, n) { if (s[i] == '1') { pr1[i] = (pr1[i - 1] + r1[n - i - 1]) % (c - 1); pr2[i] = (pr2[i - 1] + r2[n - i - 1]) % (c + 1); } else { pr1[i] = pr1[i - 1]; pr2[i] = pr2[i - 1]; } // cout<<i<<" "<<pr1[i]<<" "<<pr2[i]<<endl; } if (s[n - 1] == '1') sr1[n - 1] = r1[0], sr2[n - 1] = r2[0]; rrep(i, n - 2, 0) { if (s[i] == '1') { sr1[i] = (sr1[i + 1] + r1[n - i - 1]) % (c - 1); sr2[i] = (sr2[i + 1] + r2[n - i - 1]) % (c + 1); } else { sr1[i] = sr1[i + 1]; sr2[i] = sr2[i + 1]; } // cout<<i<<" "<<sr1[i]<<" "<<sr2[i]<<endl; } rep(i, 0, n) { if (i == 0) { if (s[i] == '1') { cout << cnt[sr1[i + 1]] + 1 << endl; } else { ll r = (r2[n - i - 1] + sr2[i + 1]) % (c + 1); cout << cnt[r] + 1 << endl; } } else if (i == n - 1) { if (s[i] == '1') { cout << cnt[pr1[i - 1]] + 1 << endl; } else { ll r = (r2[n - i - 1] + pr2[i - 1]) % (c + 1); cout << cnt[r] + 1 << endl; } } else { if (s[i] == '1') { ll r = (pr1[i - 1] + sr1[i + 1]) % (c - 1); cout << cnt[r] + 1 << endl; } else { ll r = (pr2[i - 1] + sr2[i + 1] + r2[n - 1 - i]) % (c + 1); cout << cnt[r] + 1 << endl; } } } }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define sec second #define fir first #define mo 1000000007 #define inf 1e18 #define rep(i, s, n) for (ll i = s; i < n; i = i + 1) #define rrep(i, s, n) for (ll i = s; i >= n; i--) ll mod(ll n) { return (n % (ll)mo + (ll)mo) % (ll)mo; } int main() { ll n; cin >> n; string s; cin >> s; ll c = 0; rep(i, 0, n) { if (s[i] == '1') ++c; } if (c == 0) { rep(i, 0, n) { cout << 1 << endl; } return 0; } if (c == 1) { rep(i, 0, n - 1) { if (s[i] == '0') { if (s[n - 1] != '1') cout << 1 << endl; else cout << 2 << endl; } else { cout << 0 << endl; } } if (s[n - 1] == '0') cout << 2 << endl; else cout << 0 << endl; return 0; } vector<ll> cnt(n + 1, 0); cnt[1] = 1; cnt[2] = 1; rep(i, 3, n + 1) { ll x = __builtin_popcount(i); cnt[i] = cnt[i % x] + 1; } vector<ll> r1(n + 1), r2(n + 1); r1[0] = 1 % (c - 1); r2[0] = 1 % (c + 1); rep(i, 1, n) { r1[i] = (r1[i - 1] * 2) % (c - 1); r2[i] = (r2[i - 1] * 2) % (c + 1); } vector<ll> pr1(n + 1, 0), pr2(n + 1, 0); vector<ll> sr1(n + 2, 0), sr2(n + 2, 0); if (s[0] == '1') pr1[0] = r1[n - 1], pr2[0] = r2[n - 1]; rep(i, 1, n) { if (s[i] == '1') { pr1[i] = (pr1[i - 1] + r1[n - i - 1]) % (c - 1); pr2[i] = (pr2[i - 1] + r2[n - i - 1]) % (c + 1); } else { pr1[i] = pr1[i - 1]; pr2[i] = pr2[i - 1]; } // cout<<i<<" "<<pr1[i]<<" "<<pr2[i]<<endl; } if (s[n - 1] == '1') sr1[n - 1] = r1[0], sr2[n - 1] = r2[0]; rrep(i, n - 2, 0) { if (s[i] == '1') { sr1[i] = (sr1[i + 1] + r1[n - i - 1]) % (c - 1); sr2[i] = (sr2[i + 1] + r2[n - i - 1]) % (c + 1); } else { sr1[i] = sr1[i + 1]; sr2[i] = sr2[i + 1]; } // cout<<i<<" "<<sr1[i]<<" "<<sr2[i]<<endl; } rep(i, 0, n) { if (i == 0) { if (s[i] == '1') { cout << cnt[sr1[i + 1]] + 1 << endl; } else { ll r = (r2[n - i - 1] + sr2[i + 1]) % (c + 1); cout << cnt[r] + 1 << endl; } } else if (i == n - 1) { if (s[i] == '1') { cout << cnt[pr1[i - 1]] + 1 << endl; } else { ll r = (r2[n - i - 1] + pr2[i - 1]) % (c + 1); cout << cnt[r] + 1 << endl; } } else { if (s[i] == '1') { ll r = (pr1[i - 1] + sr1[i + 1]) % (c - 1); cout << cnt[r] + 1 << endl; } else { ll r = (pr2[i - 1] + sr2[i + 1] + r2[n - 1 - i]) % (c + 1); cout << cnt[r] + 1 << endl; } } } }
insert
27
27
27
50
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> // #include <math.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; const int MOD = (int)1e9 + 7; const double PI = 3.14159265358979323846; int popCnt(int x) { return __builtin_popcount(x); } int f(int x) { if (x == 0) return 0; return f(x % popCnt(x)) + 1; } int main(void) { int n; string s; cin >> n >> s; vector<int> x(n); rep(i, n) x[i] = s[i] - '0'; int pc = 0; rep(i, n) pc += x[i]; vector<int> ans(n); rep(b, 2) { int npc = pc; if (b == 0) { npc++; } else { npc--; } int r; rep(i, n) { r = (r * 2) % npc; r += x[i]; } int k = 1; for (int i = n - 1; i >= 0; i--) { if (x[i] == b) { int nr; if (b == 0) { nr = (r + k) % npc; } else { nr = (r - k + npc) % npc; } ans[i] = f(nr) + 1; } k = (k * 2) % npc; } } rep(i, n) cout << ans[i] << endl; return 0; }
#include <bits/stdc++.h> // #include <math.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; const int MOD = (int)1e9 + 7; const double PI = 3.14159265358979323846; int popCnt(int x) { return __builtin_popcount(x); } int f(int x) { if (x == 0) return 0; return f(x % popCnt(x)) + 1; } int main(void) { int n; string s; cin >> n >> s; vector<int> x(n); rep(i, n) x[i] = s[i] - '0'; int pc = 0; rep(i, n) pc += x[i]; vector<int> ans(n); rep(b, 2) { int npc = pc; if (b == 0) { npc++; } else { npc--; } if (npc <= 0) continue; int r = 0; rep(i, n) { r = (r * 2) % npc; r += x[i]; } int k = 1; for (int i = n - 1; i >= 0; i--) { if (x[i] == b) { int nr; if (b == 0) { nr = (r + k) % npc; } else { nr = (r - k + npc) % npc; } ans[i] = f(nr) + 1; } k = (k * 2) % npc; } } rep(i, n) cout << ans[i] << endl; return 0; }
replace
31
32
31
34
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<int, int> pii; template <class Type> void line(const Type &a) { int cnt = 0; for (const auto &elem : a) { if (cnt++) cerr << ' '; cout << elem; } cerr << endl; } int count_bits(unsigned x) { return (x == 0) ? 0 : count_bits(x >> 1) + (x & 1); } // 自然数のビット数を求める. template <class Type_k, class Type_p> Type_p mod_pow(long long n, Type_k k, Type_p p) { // n^k(mod p). if (k == 0) return 1; long long res = mod_pow(n * n % p, k / 2, p); if (k & 1) res = res * n % p; return res; } // ツイッター参考. int main() { // 大きくてもn桁なので1回目の操作でn=0~n-1になる! int n; string s; cin >> n >> s; vi dp(n); // dp[i]:=f(i) (i:0~n-1). dp[0] = 0; for (int i = 1; i < n; ++i) { int tmp = count_bits(i); dp[i] = dp[i % tmp] + 1; } int num = 0; // sの'1'の数. int sum[2] = {}; // mod num+1とnum-1の場合の合計. REP(i, n) { if (s[i] == '1') num++; } REP(i, n) { if (s[i] == '1') { sum[0] = (sum[0] + mod_pow(2LL, n - 1 - i, num + 1)) % (num + 1); sum[1] = (sum[1] + mod_pow(2LL, n - 1 - i, num - 1)) % (num - 1); } } REP(i, n) { if (s[i] == '0') { int tmp = (sum[0] + mod_pow(2LL, n - 1 - i, num + 1)) % (num + 1); cout << dp[tmp] + 1 << endl; } else { if (num == 1) cout << 0 << endl; // 0割り防止! else { int tmp = ((num - 1) + sum[1] - mod_pow(2LL, n - 1 - i, num - 1)) % (num - 1); cout << dp[tmp] + 1 << endl; } } } }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<int, int> pii; template <class Type> void line(const Type &a) { int cnt = 0; for (const auto &elem : a) { if (cnt++) cerr << ' '; cout << elem; } cerr << endl; } int count_bits(unsigned x) { return (x == 0) ? 0 : count_bits(x >> 1) + (x & 1); } // 自然数のビット数を求める. template <class Type_k, class Type_p> Type_p mod_pow(long long n, Type_k k, Type_p p) { // n^k(mod p). if (k == 0) return 1; long long res = mod_pow(n * n % p, k / 2, p); if (k & 1) res = res * n % p; return res; } // ツイッター参考. int main() { // 大きくてもn桁なので1回目の操作でn=0~n-1になる! int n; string s; cin >> n >> s; vi dp(n); // dp[i]:=f(i) (i:0~n-1). dp[0] = 0; for (int i = 1; i < n; ++i) { int tmp = count_bits(i); dp[i] = dp[i % tmp] + 1; } int num = 0; // sの'1'の数. int sum[2] = {}; // mod num+1とnum-1の場合の合計. REP(i, n) { if (s[i] == '1') num++; } REP(i, n) { if (s[i] == '1') { sum[0] = (sum[0] + mod_pow(2LL, n - 1 - i, num + 1)) % (num + 1); if (num > 1) sum[1] = (sum[1] + mod_pow(2LL, n - 1 - i, num - 1)) % (num - 1); } } REP(i, n) { if (s[i] == '0') { int tmp = (sum[0] + mod_pow(2LL, n - 1 - i, num + 1)) % (num + 1); cout << dp[tmp] + 1 << endl; } else { if (num == 1) cout << 0 << endl; // 0割り防止! else { int tmp = ((num - 1) + sum[1] - mod_pow(2LL, n - 1 - i, num - 1)) % (num - 1); cout << dp[tmp] + 1 << endl; } } } }
replace
59
60
59
61
0
p02609
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> #define ll long long #define int long long #define ld long double #define endl "\n" #define debugv(v) \ cerr << #v << " : "; \ for (auto x : v) \ cerr << x << ' '; \ cerr << endl; #define debug(x) cerr << #x << '=' << (x) << endl; #define debugp(p) cerr << #p << '=' << (p.first) << " " << p.second << endl; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define output(x) cout << (x ? "YES" : "NO") << endl; const ll MOD = 1e9 + 7; const int N = 1e4 + 5; const int demo = 10; using namespace std; const ll cfmod = 998244353; ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; char button[4] = {'L', 'R', 'U', 'D'}; // Ahhiya thi lakhvanu chalu thasse.... int calc(int first, int x) { int ones = 0; int sec = first; while (sec) { if (sec % 2) { ones++; } sec /= 2; } if (ones == 0) return 0; if (ones == 1) return 1; return 1 + calc(first % ones, ones); } signed main() { FAST int q = 1; // cin>>q; while (q--) { int n; cin >> n; string s; cin >> s; int arr[2][n]; int ones = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { ones++; } } if (ones > 0) { // ones-1 int x = ones - 1; int num = 1; int curr = 0; for (int i = n - 1; i >= 0; i--) { arr[0][i] = num; num *= 2; num %= x; } int sum0 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum0 += arr[0][i]; } } x = ones + 1; num = 1; for (int i = n - 1; i >= 0; i--) { arr[1][i] = num; num *= 2; num %= x; } int sum1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum1 += arr[1][i]; } } // debugv(arr[1]) // cout<<sum0<<" "<<sum1<<endl; // main ans for (int i = 0; i < n; i++) { if (s[i] == '1') { x = ones - 1; int shrey = sum0 - arr[0][i] + x; int p = 1 + calc(shrey % x, x); cout << p << endl; // debug(shrey) } else { x = ones + 1; int shrey = sum1 + arr[1][i]; int p = 1 + calc(shrey % x, x); cout << p << endl; // debug(shrey) } } // ones+1 } else { for (int i = 0; i < n; i++) { cout << 1 << endl; } } } }
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> #define ll long long #define int long long #define ld long double #define endl "\n" #define debugv(v) \ cerr << #v << " : "; \ for (auto x : v) \ cerr << x << ' '; \ cerr << endl; #define debug(x) cerr << #x << '=' << (x) << endl; #define debugp(p) cerr << #p << '=' << (p.first) << " " << p.second << endl; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define output(x) cout << (x ? "YES" : "NO") << endl; const ll MOD = 1e9 + 7; const int N = 1e4 + 5; const int demo = 10; using namespace std; const ll cfmod = 998244353; ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; char button[4] = {'L', 'R', 'U', 'D'}; // Ahhiya thi lakhvanu chalu thasse.... int calc(int first, int x) { int ones = 0; int sec = first; while (sec) { if (sec % 2) { ones++; } sec /= 2; } if (ones == 0) return 0; if (ones == 1) return 1; return 1 + calc(first % ones, ones); } signed main() { FAST int q = 1; // cin>>q; while (q--) { int n; cin >> n; string s; cin >> s; int arr[2][n]; int ones = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { ones++; } } if (ones == 1) { int x = ones + 1; int num = 1; for (int i = n - 1; i >= 0; i--) { arr[1][i] = num; num *= 2; num %= x; } int sum1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum1 += arr[1][i]; } } // debugv(arr[1]) // cout<<sum0<<" "<<sum1<<endl; // main ans for (int i = 0; i < n; i++) { if (s[i] == '1') { cout << 0 << endl; } else { x = ones + 1; int shrey = sum1 + arr[1][i]; int p = 1 + calc(shrey % x, x); cout << p << endl; // debug(shrey) } } // ones+1 } else if (ones > 0) { // ones-1 int x = ones - 1; int num = 1; int curr = 0; for (int i = n - 1; i >= 0; i--) { arr[0][i] = num; num *= 2; num %= x; } int sum0 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum0 += arr[0][i]; } } x = ones + 1; num = 1; for (int i = n - 1; i >= 0; i--) { arr[1][i] = num; num *= 2; num %= x; } int sum1 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum1 += arr[1][i]; } } // debugv(arr[1]) // cout<<sum0<<" "<<sum1<<endl; // main ans for (int i = 0; i < n; i++) { if (s[i] == '1') { x = ones - 1; int shrey = sum0 - arr[0][i] + x; int p = 1 + calc(shrey % x, x); cout << p << endl; // debug(shrey) } else { x = ones + 1; int shrey = sum1 + arr[1][i]; int p = 1 + calc(shrey % x, x); cout << p << endl; // debug(shrey) } } // ones+1 } else { for (int i = 0; i < n; i++) { cout << 1 << endl; } } } }
replace
76
77
76
107
0
p02609
C++
Runtime Error
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // #include<boost/multiprecision/cpp_int.hpp> // #include <boost/math/common_factor.hpp> // namespace mp=boost::multiprecision; #define ll long long #define mod 1000000007 #define fi first #define se second #define inf 4e18 #define lim 1000000000000 #define pll pair<ll, ll> #define pb push_back #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define el "\n" #define vll vector<ll> #define vpll vector<pll> #define vppll vector<pair<ll, pll>> #define vvll vector<vector<ll>> #define vvc vector<vector<char>> #define vc vector<char> // #define mod 998244353 ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll xpow(ll a, ll b, ll m) { if (!b) return 1; if (b == 1) return a; if (b & 1) { return ((a * xpow(a, b - 1, m)) % m); } else { ll p = xpow(a, b / 2, m); return ((p * p) % m); } } /*double xpow(double a,ll b) { if(!b) return 1; if(b==1) return a; if(b&1) { return((a*xpow(a,b-1))); } else { p=xpow(a,b/2); return((p*p)); } } void dfs(ll v,vector<vector<ll> > &edge,vector<bool> &vis) { vis[v]=1; for(ll i=0;i<edge[v].size();i++) { ll v1=edge[v][i]; if(!vis[v1]) { dfs(v1,edge,vis; } } } ll parent(ll x,vector<ll> &par) { if(par[x]==x) return(x); par[x]=parent(par[x],par); return(par[x]); } bool uni(ll a,ll b,vector<ll> &par) { ll pa=parent(a,par); ll pb=parent(b,par); if(pa==pb) return 0; else { par[pa]=pb; return 1; } } void seive(vector<bool> &v) { ll n=v.size(); for(ll i=2;i*i<n;i++) { if(v[i]) { for(ll j=i*i;j<n;j+=i) v[j]=0; } } } void bfs(ll v,vector<vector<ll> > &edge,vector<bool> &vis,vector<ll> &level) { queue<ll> q; q.push(v); vis[v]=1; level[v]=0; while(!q.empty()) { ll ve=q.front();q.pop(); for(ll i=0;i<edge[ve].size();i++) { ll vee=edge[ve][i]; if(!vis[vee]) { vis[vee]=1; level[vee]=level[ve]+1; q.push(vee); } } } } ll solve(ll x,ll n) { ll low=0,high=2e9,mid; ll ans=x; while(low<high) { mid=low+(high-low)/2; ll val=(mid*(mid+1))/2; if(val>=x) { ans=mid; high=mid; } else { low=mid+1; } } return(ans); } bool chk(ll vv,vector<ll> &v) { for(auto p:v) { if(p==vv) return 0; } return 1; } ll phi(ll n) { ll ans=n; for(ll i=2;i*i<=n;i++) { if(n%i) continue; while(n%i==0) { n/=i; } ans=ans-ans/i; } if(n>1) ans-=ans/n; return(ans); } ll tr[800005]; void build(ll node,ll l,ll r,vector<ll> &v) { if(l==r) { tr[node]=v[l]; return; } ll mid=(l+r)/2; build(2*node+1,l,mid,v); build(2*node+2,mid+1,r,v); tr[node]=max(tr[2*node+1],tr[2*node+2]); } ll query(ll node,ll s,ll e,ll l,ll r) { if(e<l || s>r) return 0; if(s>=l&&e<=r) return(tr[node]); ll mid=(s+e)/2; ll m1=query(2*node+1,s,mid,l,r); ll m2=query(2*node+2,mid+1,e,l,r); return(max(m1,m2)); } ll nCr(ll n,ll r) { ll ans=1; for(ll i=1;i<=n-r;i++) { ans=(ans*((r+i))); ans/=i; ans%=mod; //ans/=i; } ans%=mod; return(ans); } void djks(ll v,vvll &edge,vvll &dist) { ll n=edge.size()-1; vll dis(n+1,inf); priority_queue<pll> pq; dis[v]=0; pq.push({0,v}); while(!pq.empty()) { pll p=pq.top();pq.pop(); p.fi*=-1; for(ll i=1;i<=n;i++) { if(edge[p.se][i]) { if(dis[i]>(dis[p.se]+edge[p.se][i])) { dis[i]=dis[p.se]+edge[p.se][i]; pq.push({-dis[i],i}); } } } } for(ll i=1;i<=n;i++) { dist[v][i]=dis[i]; } } ll kmp(string &s) { string t=s; reverse(all(t)); string a=s+"#"+t; ll n=a.size(); vll nxt(n); nxt[0]=0; ll i=0,j=1; while(j<n) { if(a[i]==a[j]) { nxt[j]=i+1; i++;j++; } else { if(i) i=nxt[i-1]; else { nxt[j]=0; j++; } } } return(nxt[n-1]); } string sadd(string a,string b) { string t; ll la=a.length(),lb=b.length(); ll d=0; ll i=la-1,j=lb-1; while(i>=0 && j>=0) { ll x=a[i]-'0',y=b[j]-'0'; t.pb((x+y+d)%10+'0'); d=(x+y+d)/10; i--;j--; } while(i>=0) { ll x=a[i]-'0'; t.pb((x+d)%10+'0'); d=(x+d)/10;i--; } while(j>=0) { ll y=b[j]-'0'; t.pb((y+d)%10+'0'); d=(y+d)/10;j--; } while(d) { t.pb(d%10+'0'); d/=10; } //cout<<a<<" "<<b<<el; reverse(all(t)); return(t); }*/ const ll zzz = 1e3 + 5; ll nCr[zzz][zzz]; void cal() { nCr[0][0] = 1; for (ll i = 1; i < zzz; i++) { nCr[i][0] = 1; for (ll j = 1; j < zzz; j++) { nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % mod; } } } const ll N = 1e5 + 5; bool check_prime(ll n) { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return 0; } return 1; } ll solve(ll num) { if (num == 0) return 0; ll c = 0; ll t = num; while (t) { if (t & 1) c++; t >>= 1; } return (1 + solve(num % c)); } void doit() { ll n; cin >> n; string s; cin >> s; vll pwr(n + 1, 0); ll no = 0; for (auto c : s) { if (c == '1') no++; } ll modd = no + 1; if (no - 1 > 0) modd *= (no - 1); pwr[n - 1] = 1 % modd; for (ll i = n - 2; i >= 0; i--) { pwr[i] = (2 * pwr[i + 1]) % modd; } ll sum = 0; for (ll i = 0; i < n; i++) { if (s[i] == '1') { sum = (pwr[i] + sum) % modd; } } for (ll i = 0; i < n; i++) { ll ans; if (s[i] == '1') { ans = 1 + solve((sum - pwr[i] + modd) % (no - 1)); } else { ans = 1 + solve((sum + pwr[i] + modd) % (no + 1)); } cout << ans << el; } cout << el; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cal(); // For nCr; // Array of length 5e6 can be made...and I think questions are also within // range 2^17>10^5 and 2^16<10^5 ll t; t = 1; // cin>>t; while (t--) { doit(); } return 0; }
// #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // #include<boost/multiprecision/cpp_int.hpp> // #include <boost/math/common_factor.hpp> // namespace mp=boost::multiprecision; #define ll long long #define mod 1000000007 #define fi first #define se second #define inf 4e18 #define lim 1000000000000 #define pll pair<ll, ll> #define pb push_back #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define el "\n" #define vll vector<ll> #define vpll vector<pll> #define vppll vector<pair<ll, pll>> #define vvll vector<vector<ll>> #define vvc vector<vector<char>> #define vc vector<char> // #define mod 998244353 ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll xpow(ll a, ll b, ll m) { if (!b) return 1; if (b == 1) return a; if (b & 1) { return ((a * xpow(a, b - 1, m)) % m); } else { ll p = xpow(a, b / 2, m); return ((p * p) % m); } } /*double xpow(double a,ll b) { if(!b) return 1; if(b==1) return a; if(b&1) { return((a*xpow(a,b-1))); } else { p=xpow(a,b/2); return((p*p)); } } void dfs(ll v,vector<vector<ll> > &edge,vector<bool> &vis) { vis[v]=1; for(ll i=0;i<edge[v].size();i++) { ll v1=edge[v][i]; if(!vis[v1]) { dfs(v1,edge,vis; } } } ll parent(ll x,vector<ll> &par) { if(par[x]==x) return(x); par[x]=parent(par[x],par); return(par[x]); } bool uni(ll a,ll b,vector<ll> &par) { ll pa=parent(a,par); ll pb=parent(b,par); if(pa==pb) return 0; else { par[pa]=pb; return 1; } } void seive(vector<bool> &v) { ll n=v.size(); for(ll i=2;i*i<n;i++) { if(v[i]) { for(ll j=i*i;j<n;j+=i) v[j]=0; } } } void bfs(ll v,vector<vector<ll> > &edge,vector<bool> &vis,vector<ll> &level) { queue<ll> q; q.push(v); vis[v]=1; level[v]=0; while(!q.empty()) { ll ve=q.front();q.pop(); for(ll i=0;i<edge[ve].size();i++) { ll vee=edge[ve][i]; if(!vis[vee]) { vis[vee]=1; level[vee]=level[ve]+1; q.push(vee); } } } } ll solve(ll x,ll n) { ll low=0,high=2e9,mid; ll ans=x; while(low<high) { mid=low+(high-low)/2; ll val=(mid*(mid+1))/2; if(val>=x) { ans=mid; high=mid; } else { low=mid+1; } } return(ans); } bool chk(ll vv,vector<ll> &v) { for(auto p:v) { if(p==vv) return 0; } return 1; } ll phi(ll n) { ll ans=n; for(ll i=2;i*i<=n;i++) { if(n%i) continue; while(n%i==0) { n/=i; } ans=ans-ans/i; } if(n>1) ans-=ans/n; return(ans); } ll tr[800005]; void build(ll node,ll l,ll r,vector<ll> &v) { if(l==r) { tr[node]=v[l]; return; } ll mid=(l+r)/2; build(2*node+1,l,mid,v); build(2*node+2,mid+1,r,v); tr[node]=max(tr[2*node+1],tr[2*node+2]); } ll query(ll node,ll s,ll e,ll l,ll r) { if(e<l || s>r) return 0; if(s>=l&&e<=r) return(tr[node]); ll mid=(s+e)/2; ll m1=query(2*node+1,s,mid,l,r); ll m2=query(2*node+2,mid+1,e,l,r); return(max(m1,m2)); } ll nCr(ll n,ll r) { ll ans=1; for(ll i=1;i<=n-r;i++) { ans=(ans*((r+i))); ans/=i; ans%=mod; //ans/=i; } ans%=mod; return(ans); } void djks(ll v,vvll &edge,vvll &dist) { ll n=edge.size()-1; vll dis(n+1,inf); priority_queue<pll> pq; dis[v]=0; pq.push({0,v}); while(!pq.empty()) { pll p=pq.top();pq.pop(); p.fi*=-1; for(ll i=1;i<=n;i++) { if(edge[p.se][i]) { if(dis[i]>(dis[p.se]+edge[p.se][i])) { dis[i]=dis[p.se]+edge[p.se][i]; pq.push({-dis[i],i}); } } } } for(ll i=1;i<=n;i++) { dist[v][i]=dis[i]; } } ll kmp(string &s) { string t=s; reverse(all(t)); string a=s+"#"+t; ll n=a.size(); vll nxt(n); nxt[0]=0; ll i=0,j=1; while(j<n) { if(a[i]==a[j]) { nxt[j]=i+1; i++;j++; } else { if(i) i=nxt[i-1]; else { nxt[j]=0; j++; } } } return(nxt[n-1]); } string sadd(string a,string b) { string t; ll la=a.length(),lb=b.length(); ll d=0; ll i=la-1,j=lb-1; while(i>=0 && j>=0) { ll x=a[i]-'0',y=b[j]-'0'; t.pb((x+y+d)%10+'0'); d=(x+y+d)/10; i--;j--; } while(i>=0) { ll x=a[i]-'0'; t.pb((x+d)%10+'0'); d=(x+d)/10;i--; } while(j>=0) { ll y=b[j]-'0'; t.pb((y+d)%10+'0'); d=(y+d)/10;j--; } while(d) { t.pb(d%10+'0'); d/=10; } //cout<<a<<" "<<b<<el; reverse(all(t)); return(t); }*/ const ll zzz = 1e3 + 5; ll nCr[zzz][zzz]; void cal() { nCr[0][0] = 1; for (ll i = 1; i < zzz; i++) { nCr[i][0] = 1; for (ll j = 1; j < zzz; j++) { nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % mod; } } } const ll N = 1e5 + 5; bool check_prime(ll n) { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return 0; } return 1; } ll solve(ll num) { if (num == 0) return 0; ll c = 0; ll t = num; while (t) { if (t & 1) c++; t >>= 1; } return (1 + solve(num % c)); } void doit() { ll n; cin >> n; string s; cin >> s; vll pwr(n + 1, 0); ll no = 0; for (auto c : s) { if (c == '1') no++; } ll modd = no + 1; if (no - 1 > 0) modd *= (no - 1); pwr[n - 1] = 1 % modd; for (ll i = n - 2; i >= 0; i--) { pwr[i] = (2 * pwr[i + 1]) % modd; } ll sum = 0; for (ll i = 0; i < n; i++) { if (s[i] == '1') { sum = (pwr[i] + sum) % modd; } } for (ll i = 0; i < n; i++) { ll ans; if (s[i] == '1') { if (no == 1) ans = 0; else ans = 1 + solve((sum - pwr[i] + modd) % (no - 1)); } else { ans = 1 + solve((sum + pwr[i] + modd) % (no + 1)); } cout << ans << el; } cout << el; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cal(); // For nCr; // Array of length 5e6 can be made...and I think questions are also within // range 2^17>10^5 and 2^16<10^5 ll t; t = 1; // cin>>t; while (t--) { doit(); } return 0; }
replace
365
366
365
369
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) // #define rep(i, n) for (ll i = 0; i < (n); ++i) typedef pair<ll, ll> P; const ll INF = 10e17; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) #define ret() return 0; double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; } std::istream &operator>>(std::istream &in, set<int> &o) { int a; in >> a; o.insert(a); return in; } std::istream &operator>>(std::istream &in, queue<int> &o) { ll a; in >> a; o.push(a); return in; } bool contain(set<int> &s, int a) { return s.find(a) != s.end(); } // ofstream outfile("log.txt"); // outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') // << rank << endl; // std::cout << std::bitset<8>(9); // const ll mod = 1e10; typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK; ll f(ll l) { int ans = 0; while (l > 0) { ans++; l %= __builtin_popcountll(l); } return ans; } int main() { int n; string s; cin >> n >> s; reverse(s.begin(), s.end()); int pc = count(s.begin(), s.end(), '1'); auto fac = [&](int i) -> vector<int> { vector<int> v(n, 0); int prev = 1 % i; rep(j, n) { v[j] = prev; prev *= 2; prev %= i; } return v; }; vector<int> fac_up = fac(pc + 1); vector<int> fac_down = fac(pc - 1); auto ini = [&](int i, vector<int> &fac) -> int { if (i == 0) return -1; int prev = 0; rep(j, n) { if (s[j] == '1') prev += fac[j]; prev %= i; } return prev; }; int ini_up = ini(pc + 1, fac_up); int ini_down = ini(pc - 1, fac_down); vector<int> ans; rep(i, n) { if (s[i] == '0') { int pu = pc + 1; int now = (pu + ini_up + fac_up[i]) % pu; ans.push_back(f(now) + 1); } else { int pd = pc - 1; if (pd == 0) { ans.push_back(0); continue; } int now = (pd + ini_down - fac_down[i]) % pd; ans.push_back(f(now) + 1); } } reverse(ans.begin(), ans.end()); for (int i : ans) cout << i << endl; }
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) // #define rep(i, n) for (ll i = 0; i < (n); ++i) typedef pair<ll, ll> P; const ll INF = 10e17; #define cmin(x, y) x = min(x, y) #define cmax(x, y) x = max(x, y) #define ret() return 0; double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; } std::istream &operator>>(std::istream &in, set<int> &o) { int a; in >> a; o.insert(a); return in; } std::istream &operator>>(std::istream &in, queue<int> &o) { ll a; in >> a; o.push(a); return in; } bool contain(set<int> &s, int a) { return s.find(a) != s.end(); } // ofstream outfile("log.txt"); // outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') // << rank << endl; // std::cout << std::bitset<8>(9); // const ll mod = 1e10; typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK; ll f(ll l) { int ans = 0; while (l > 0) { ans++; l %= __builtin_popcountll(l); } return ans; } int main() { int n; string s; cin >> n >> s; reverse(s.begin(), s.end()); int pc = count(s.begin(), s.end(), '1'); auto fac = [&](int i) -> vector<int> { if (i == 0) return vector<int>(0); vector<int> v(n, 0); int prev = 1 % i; rep(j, n) { v[j] = prev; prev *= 2; prev %= i; } return v; }; vector<int> fac_up = fac(pc + 1); vector<int> fac_down = fac(pc - 1); auto ini = [&](int i, vector<int> &fac) -> int { if (i == 0) return -1; int prev = 0; rep(j, n) { if (s[j] == '1') prev += fac[j]; prev %= i; } return prev; }; int ini_up = ini(pc + 1, fac_up); int ini_down = ini(pc - 1, fac_down); vector<int> ans; rep(i, n) { if (s[i] == '0') { int pu = pc + 1; int now = (pu + ini_up + fac_up[i]) % pu; ans.push_back(f(now) + 1); } else { int pd = pc - 1; if (pd == 0) { ans.push_back(0); continue; } int now = (pd + ini_down - fac_down[i]) % pd; ans.push_back(f(now) + 1); } } reverse(ans.begin(), ans.end()); for (int i : ans) cout << i << endl; }
insert
62
62
62
64
0
p02609
C++
Runtime Error
// K-OS WITH THE OCDE #include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef long double db; #define TEST \ ll t; \ cin >> t; \ while (t--) #define vell vector<ll> #define pl pair<ll, ll> #define all(v) v.begin(), v.end() #define pb push_back #define ff first #define ss second #define mp make_pair #define dbg(x) cerr << #x << ": " << x << endl #define dbg2(x, y) cerr << #x << ": " << x << " || " << #y << ": " << y << endl #define endl "\n" #define MAX 1e18 #define MIN INT_MIN // #define mod 1000000007 const int mxn = 2e5 + 2; int gre[200005]; ll low[200005]; ll store[mxn]; ll mult(ll x, ll y, ll mod) { return (((x % mod) * (y % mod)) % mod); } void pre() { for (ll i = 0; i < mxn; ++i) { ll x = i; ll count = 0; while (x) { ll y = __builtin_popcount(x); x %= y; count++; } store[i] = count; } // dbg2(store[1] , store[0]); } void prel(ll k, ll n) { low[0] = 1 % k; for (ll i = 1; i < n; ++i) { low[i] = mult(low[i - 1], (2 % k), k); low[i] %= k; // cout << low[i] << " "; } } void preg(ll k, ll n) { gre[0] = 1 % k; for (ll i = 1; i < n; ++i) { gre[i] = mult(gre[i - 1], (2 % k), k); gre[i] %= k; // cout << gre[i] << " "; } } ll small = 0, large = 0; void sl(ll k, string s, ll n) { ll i = 0, j = n - 1; while (i < n) { if (s[j] == '1') { small += low[i]; small %= k; } i++; j--; } } void sg(ll k, string s, ll n) { ll i = 0, j = n - 1; while (i < n) { if (s[j] == '1') { large += gre[i]; large %= k; } i++; j--; } } void solve() { ll n; cin >> n; string s; cin >> s; ll f = 0; for (ll i = 0; i < n; ++i) { f += (s[i] == '1'); } if (f - 1) prel(f - 1, n); preg(f + 1, n); if (f - 1) sl(f - 1, s, n); sg(f + 1, s, n); for (ll i = 0; i < n; ++i) { ll x; if (s[i] == '1' && (f - 1)) { x = (small - low[n - i - 1] + (f - 1)) % (f - 1); } else if (s[i] == '0') { x = (large + gre[n - i - 1] + (f + 1)); x %= (f + 1); } cout << 1 + store[x] << endl; } } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); // TEST pre(); solve(); }
// K-OS WITH THE OCDE #include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef long double db; #define TEST \ ll t; \ cin >> t; \ while (t--) #define vell vector<ll> #define pl pair<ll, ll> #define all(v) v.begin(), v.end() #define pb push_back #define ff first #define ss second #define mp make_pair #define dbg(x) cerr << #x << ": " << x << endl #define dbg2(x, y) cerr << #x << ": " << x << " || " << #y << ": " << y << endl #define endl "\n" #define MAX 1e18 #define MIN INT_MIN // #define mod 1000000007 const int mxn = 2e5 + 2; int gre[200005]; ll low[200005]; ll store[mxn]; ll mult(ll x, ll y, ll mod) { return (((x % mod) * (y % mod)) % mod); } void pre() { for (ll i = 0; i < mxn; ++i) { ll x = i; ll count = 0; while (x) { ll y = __builtin_popcount(x); x %= y; count++; } store[i] = count; } // dbg2(store[1] , store[0]); } void prel(ll k, ll n) { low[0] = 1 % k; for (ll i = 1; i < n; ++i) { low[i] = mult(low[i - 1], (2 % k), k); low[i] %= k; // cout << low[i] << " "; } } void preg(ll k, ll n) { gre[0] = 1 % k; for (ll i = 1; i < n; ++i) { gre[i] = mult(gre[i - 1], (2 % k), k); gre[i] %= k; // cout << gre[i] << " "; } } ll small = 0, large = 0; void sl(ll k, string s, ll n) { ll i = 0, j = n - 1; while (i < n) { if (s[j] == '1') { small += low[i]; small %= k; } i++; j--; } } void sg(ll k, string s, ll n) { ll i = 0, j = n - 1; while (i < n) { if (s[j] == '1') { large += gre[i]; large %= k; } i++; j--; } } void solve() { ll n; cin >> n; string s; cin >> s; ll f = 0; for (ll i = 0; i < n; ++i) { f += (s[i] == '1'); } if (f - 1) prel(f - 1, n); preg(f + 1, n); if (f - 1) sl(f - 1, s, n); sg(f + 1, s, n); for (ll i = 0; i < n; ++i) { ll x = 0; if (s[i] == '1' && f - 1 == 0) { cout << 0 << endl; continue; } if (s[i] == '1') { x = (small - low[n - i - 1] + (f - 1)) % (f - 1); } else if (s[i] == '0') { x = (large + gre[n - i - 1] + (f + 1)); x %= (f + 1); } cout << 1 + store[x] << endl; } } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); // TEST pre(); solve(); }
replace
142
144
142
149
-11
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define FOR(i, b, e) for (int(i) = (b); (i) < (e); ++(i)) #define ALL(c) (c).begin(), (c).end() #define PRINT(x) cout << (x) << "\n" using namespace std; using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>; template <typename T> auto compare = [](T x, T y) -> bool { return (x < y); }; const int MOD = 1000000007; ll N; string X; ll pop[200010]; ll bin[200010][3]; vector<ll> v; ll popcount(ll n) { if (n == 0) return 0; else if (pop[n] > 0) return pop[n]; ll d = __builtin_popcount(n); pop[n] = 1 + popcount(n % d); return pop[n]; } signed main() { cin >> N >> X; reverse(ALL(X)); ll B = 0; REP(i, N) if (X[i] == '1') B++; bin[0][0] = bin[0][1] = bin[0][2] = 1; REP(i, N) { if (B > 1) bin[i + 1][0] = (bin[i][0] * 2) % (B - 1); bin[i + 1][1] = (bin[i][1] * 2) % B; bin[i + 1][2] = (bin[i][2] * 2) % (B + 1); } ll Y = 0, Z = 0; REP(i, N) { if (B > 1) Y = (Y + (X[i] - '0') * bin[i][0]) % (B - 1); Z = (Z + (X[i] - '0') * bin[i][2]) % (B + 1); } REP(i, N) { if (X[i] == '0') { v.push_back(popcount((Z + bin[i][2]) % (B + 1))); } else { if (B > 1) v.push_back(popcount((Y - bin[i][0] + B - 1) % (B - 1))); else v.push_back(-1); } } REP(i, N) { PRINT(v[N - i - 1] + 1); } return 0; }
#include <bits/stdc++.h> #define REP(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define FOR(i, b, e) for (int(i) = (b); (i) < (e); ++(i)) #define ALL(c) (c).begin(), (c).end() #define PRINT(x) cout << (x) << "\n" using namespace std; using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>; template <typename T> auto compare = [](T x, T y) -> bool { return (x < y); }; const int MOD = 1000000007; ll N; string X; ll pop[200010]; ll bin[200010][3]; vector<ll> v; ll popcount(ll n) { if (n == 0) return 0; else if (pop[n] > 0) return pop[n]; ll d = __builtin_popcount(n); pop[n] = 1 + popcount(n % d); return pop[n]; } signed main() { cin >> N >> X; reverse(ALL(X)); ll B = 0; REP(i, N) if (X[i] == '1') B++; bin[0][0] = bin[0][1] = bin[0][2] = 1; REP(i, N) { if (B > 1) bin[i + 1][0] = (bin[i][0] * 2) % (B - 1); if (B > 0) bin[i + 1][1] = (bin[i][1] * 2) % B; bin[i + 1][2] = (bin[i][2] * 2) % (B + 1); } ll Y = 0, Z = 0; REP(i, N) { if (B > 1) Y = (Y + (X[i] - '0') * bin[i][0]) % (B - 1); Z = (Z + (X[i] - '0') * bin[i][2]) % (B + 1); } REP(i, N) { if (X[i] == '0') { v.push_back(popcount((Z + bin[i][2]) % (B + 1))); } else { if (B > 1) v.push_back(popcount((Y - bin[i][0] + B - 1) % (B - 1))); else v.push_back(-1); } } REP(i, N) { PRINT(v[N - i - 1] + 1); } return 0; }
replace
37
38
37
39
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl; #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define int ll #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (int)(n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout << setprecision(25) << fixed << p << endl; // int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 }; vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1}; // vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 }; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); const ll MOD = 1000000007; // const ll MOD = 998244353; // #define mp make_pair // #define endl '\n' const int MAXN = 555555; vl fact(MAXN); vl rfact(MAXN); ll mod_pow(ll x, ll p, ll M = MOD) { if (p < 0) { x = mod_pow(x, M - 2, M); p = -p; } ll a = 1; while (p) { if (p % 2) a = a * x % M; x = x * x % M; p /= 2; } return a; } ll mod_inverse(ll a, ll M = MOD) { return mod_pow(a, M - 2, M); } void set_fact(ll n, ll M = MOD) { fact[0] = 1; for (ll i = 1; i <= n; i++) { fact[i] = i * fact[i - 1] % M; } rfact[n] = mod_inverse(fact[n], M); for (ll i = n - 1; i >= 0; i--) { rfact[i] = (i + 1) * rfact[i + 1] % M; } } // http://drken1215.hatenablog.com/entry/2018/06/08/210000 // n���傫��fact���v�Z�ł��Ȃ��Ƃ��̂ق��̌v�Z���@�ɂ‚��ď����Ă��� ll nCr(ll n, ll r, ll M = MOD) { if (r > n) return 0; assert(fact[2] == 2); ll ret = fact[n]; if (rfact[r] == 0) { rfact[r] = mod_inverse(fact[r], M); } ret = (ret * rfact[r]) % M; if (rfact[n - r] == 0) { rfact[n - r] = mod_inverse(fact[n - r], M); } ret = (ret * rfact[n - r]) % M; return ret; } ll nHr(ll n, ll r) { return nCr(n + r - 1, r); } struct dice { mt19937 mt; dice() : mt(chrono::steady_clock::now().time_since_epoch().count()) {} // [0, x)の一様乱数 ll operator()(ll x) { return this->operator()(0, x); } // [x, y)の一様乱数 ll operator()(ll x, ll y) { uniform_int_distribution<ll> dist(x, y - 1); return dist(mt); } vl operator()(int n, ll x, ll y) { vl res(n); for (int i = 0; i < n; i++) res[i] = this->operator()(x, y); return res; } } rnd; signed main() { int n; cin >> n; vi ans(222222); for (int m = 1; m < 211111; m++) { ll x = m; while (x > 0) { int cnt = 0; rep(i, 60) { ll mask = 1LL << i; if (x & mask) cnt++; } ans[m]++; x %= cnt; } } string x; cin >> x; int num = 0; rep(i, n) num += x[i] == '1'; vi base(2); rep(i, 2) { int mod = num; if (i == 0) mod--; else mod++; rep(j, n) { if (x[j] == '1') { base[i] += mod_pow(2, n - 1 - j, mod); base[i] %= mod; } } } rep(i, n) { int mod = num; int idx; if (x[i] == '1') { mod--; idx = 0; } else { mod++; idx = 1; } if (mod == 0) { cout << 0 << '\n'; continue; } int temp = base[idx]; if (x[i] == '1') temp -= mod_pow(2, n - 1 - i, mod); else temp += mod_pow(2, n - 1 - i, mod); temp = (temp % mod + mod) % mod; assert(0 <= temp and temp < mod); cout << 1 + ans[temp] << '\n'; } } // void solve() { // int n; // cin >> n; // using P = pair<pii, pii>; // vector<P> sklr(n); // rep (i, n) { // int k, l, r; // cin >> k >> l >> r; // sklr[i] = P(pii(r - l, k), pii(l, r)); // } // sort(all(sklr)); // reverse(all(sklr)); // set<int> st; // rep (i, n) st.insert(i); // ll ans = 0; // rep (i, n) { // int k = sklr[i].first.second; // auto itr = st.lower_bound(k); // int score = 0; // if (itr == st.begin()) { // score = sklr[i].second.first; // itr = st.end(); // } // else { // score = sklr[i].second.second; // } // itr--; // ans += score; // st.erase(itr); // } // cout << ans << endl; // } // signed main() { // fio(); // int t; // cin >> t; // while (t--) { // solve(); // } // }
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl; #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define int ll #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (int)(n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout << setprecision(25) << fixed << p << endl; // int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 }; vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1}; // vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 }; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); const ll MOD = 1000000007; // const ll MOD = 998244353; // #define mp make_pair // #define endl '\n' const int MAXN = 555555; vl fact(MAXN); vl rfact(MAXN); ll mod_pow(ll x, ll p, ll M = MOD) { if (p < 0) { x = mod_pow(x, M - 2, M); p = -p; } ll a = 1; while (p) { if (p % 2) a = a * x % M; x = x * x % M; p /= 2; } return a; } ll mod_inverse(ll a, ll M = MOD) { return mod_pow(a, M - 2, M); } void set_fact(ll n, ll M = MOD) { fact[0] = 1; for (ll i = 1; i <= n; i++) { fact[i] = i * fact[i - 1] % M; } rfact[n] = mod_inverse(fact[n], M); for (ll i = n - 1; i >= 0; i--) { rfact[i] = (i + 1) * rfact[i + 1] % M; } } // http://drken1215.hatenablog.com/entry/2018/06/08/210000 // n���傫��fact���v�Z�ł��Ȃ��Ƃ��̂ق��̌v�Z���@�ɂ‚��ď����Ă��� ll nCr(ll n, ll r, ll M = MOD) { if (r > n) return 0; assert(fact[2] == 2); ll ret = fact[n]; if (rfact[r] == 0) { rfact[r] = mod_inverse(fact[r], M); } ret = (ret * rfact[r]) % M; if (rfact[n - r] == 0) { rfact[n - r] = mod_inverse(fact[n - r], M); } ret = (ret * rfact[n - r]) % M; return ret; } ll nHr(ll n, ll r) { return nCr(n + r - 1, r); } struct dice { mt19937 mt; dice() : mt(chrono::steady_clock::now().time_since_epoch().count()) {} // [0, x)の一様乱数 ll operator()(ll x) { return this->operator()(0, x); } // [x, y)の一様乱数 ll operator()(ll x, ll y) { uniform_int_distribution<ll> dist(x, y - 1); return dist(mt); } vl operator()(int n, ll x, ll y) { vl res(n); for (int i = 0; i < n; i++) res[i] = this->operator()(x, y); return res; } } rnd; signed main() { int n; cin >> n; vi ans(222222); for (int m = 1; m < 211111; m++) { ll x = m; while (x > 0) { int cnt = 0; rep(i, 60) { ll mask = 1LL << i; if (x & mask) cnt++; } ans[m]++; x %= cnt; } } string x; cin >> x; int num = 0; rep(i, n) num += x[i] == '1'; vi base(2); rep(i, 2) { int mod = num; if (i == 0) mod--; else mod++; rep(j, n) { if (x[j] == '1' and mod != 0) { base[i] += mod_pow(2, n - 1 - j, mod); base[i] %= mod; } } } rep(i, n) { int mod = num; int idx; if (x[i] == '1') { mod--; idx = 0; } else { mod++; idx = 1; } if (mod == 0) { cout << 0 << '\n'; continue; } int temp = base[idx]; if (x[i] == '1') temp -= mod_pow(2, n - 1 - i, mod); else temp += mod_pow(2, n - 1 - i, mod); temp = (temp % mod + mod) % mod; assert(0 <= temp and temp < mod); cout << 1 + ans[temp] << '\n'; } } // void solve() { // int n; // cin >> n; // using P = pair<pii, pii>; // vector<P> sklr(n); // rep (i, n) { // int k, l, r; // cin >> k >> l >> r; // sklr[i] = P(pii(r - l, k), pii(l, r)); // } // sort(all(sklr)); // reverse(all(sklr)); // set<int> st; // rep (i, n) st.insert(i); // ll ans = 0; // rep (i, n) { // int k = sklr[i].first.second; // auto itr = st.lower_bound(k); // int score = 0; // if (itr == st.begin()) { // score = sklr[i].second.first; // itr = st.end(); // } // else { // score = sklr[i].second.second; // } // itr--; // ans += score; // st.erase(itr); // } // cout << ans << endl; // } // signed main() { // fio(); // int t; // cin >> t; // while (t--) { // solve(); // } // }
replace
185
186
185
186
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define int long long #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define F first #define S second #define sz(x) ((int)x.size()) #define pb push_back #define pf push_front #define eb emplace_back #define all(v) (v).begin(), (v).end() #define mod 1000000007 #define mod2 998244353 #define what_is(x) cerr << #x << " is " << x << "\n"; #define sortA(v) sort(v.begin(), v.end()) #define sortD(v) sort(v.rbegin(), v.rend()) #define PI 3.14159265358979323846 #define vout(a) \ for (auto x : a) \ cout << x << " "; #define INF 1000000000000 // #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, // tree_order_statistics_node_update> // using namespace __gnu_pbds; using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; using vii = vector<pii>; using mi = multiset<int>; using mii = multiset<pii>; int lcm(int a, int b) { return (a * (b / __gcd(a, b))); } int modp(int a, int m, int n) { if (n == 0) return 1; if (n == 1) return a % m; int res = modp(a, m, n / 2); if (n % 2 == 0) return (res * res) % m; else return (a * res * res) % m; } void solve() { int n, m, t, i, l, k, r, u, v, w, j, ss, sum = 0, pos, flag = 0, count = 0; string S, T, U; // int x,y,a,b,c; cin >> n >> S; int popcnt = 0; rep(i, 0, n) popcnt += (S[i] == '1'); if (!popcnt) { rep(i, 0, n) { cout << "1\n"; } return; } int num = 0, minus1 = 0, plus1 = 0; reverse(all(S)); rep(i, 0, n) { num = (num % popcnt + (S[i] - '0') * modp(2, popcnt, i)) % popcnt; } rep(i, 0, n) { plus1 = (plus1 % (popcnt + 1) + (S[i] - '0') * modp(2, popcnt + 1, i)) % (popcnt + 1); minus1 = (minus1 % (popcnt - 1) + (S[i] - '0') * modp(2, popcnt - 1, i)) % (popcnt - 1); } vi ans(n); rep(i, 0, n) { if (S[i] == '0') { t = (plus1 + modp(2, popcnt + 1, i) + (popcnt + 1)) % (popcnt + 1); count = 1; while (t) { t = t % (__builtin_popcountll(t)); count++; } } else { t = (minus1 - modp(2, popcnt - 1, i) + (popcnt - 1)) % (popcnt - 1); count = 1; while (t) { t = t % (__builtin_popcountll(t)); count++; } } ans[i] = count; } reverse(all(ans)); for (int x : ans) cout << x << "\n"; } signed main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; int T = 0; while (t--) { T++; // cout<<"Scenario #"<<T<<":\n"; solve(); if (t) cout << "\n"; } return 0; } /* 6 4 1 3 4 5 6 2 */
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define int long long #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define F first #define S second #define sz(x) ((int)x.size()) #define pb push_back #define pf push_front #define eb emplace_back #define all(v) (v).begin(), (v).end() #define mod 1000000007 #define mod2 998244353 #define what_is(x) cerr << #x << " is " << x << "\n"; #define sortA(v) sort(v.begin(), v.end()) #define sortD(v) sort(v.rbegin(), v.rend()) #define PI 3.14159265358979323846 #define vout(a) \ for (auto x : a) \ cout << x << " "; #define INF 1000000000000 // #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, // tree_order_statistics_node_update> // using namespace __gnu_pbds; using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; using vii = vector<pii>; using mi = multiset<int>; using mii = multiset<pii>; int lcm(int a, int b) { return (a * (b / __gcd(a, b))); } int modp(int a, int m, int n) { if (n == 0) return 1; if (n == 1) return a % m; int res = modp(a, m, n / 2); if (n % 2 == 0) return (res * res) % m; else return (a * res * res) % m; } void solve() { int n, m, t, i, l, k, r, u, v, w, j, ss, sum = 0, pos, flag = 0, count = 0; string S, T, U; // int x,y,a,b,c; cin >> n >> S; int popcnt = 0; rep(i, 0, n) popcnt += (S[i] == '1'); if (!popcnt) { rep(i, 0, n) { cout << "1\n"; } return; } int num = 0, minus1 = 0, plus1 = 0; reverse(all(S)); if (popcnt == 1) { rep(i, 0, n) { plus1 = (plus1 % (popcnt + 1) + (S[i] - '0') * modp(2, popcnt + 1, i)) % (popcnt + 1); } vi ans(n); rep(i, 0, n) { if (S[i] == '0') { t = (plus1 + modp(2, popcnt + 1, i) + (popcnt + 1)) % (popcnt + 1); count = 1; while (t) { t = t % (__builtin_popcountll(t)); count++; } ans[i] = count; } else { ans[i] = 0; } } reverse(all(ans)); for (int x : ans) cout << x << "\n"; return; } rep(i, 0, n) { plus1 = (plus1 % (popcnt + 1) + (S[i] - '0') * modp(2, popcnt + 1, i)) % (popcnt + 1); minus1 = (minus1 % (popcnt - 1) + (S[i] - '0') * modp(2, popcnt - 1, i)) % (popcnt - 1); } vi ans(n); rep(i, 0, n) { if (S[i] == '0') { t = (plus1 + modp(2, popcnt + 1, i) + (popcnt + 1)) % (popcnt + 1); count = 1; while (t) { t = t % (__builtin_popcountll(t)); count++; } } else { t = (minus1 - modp(2, popcnt - 1, i) + (popcnt - 1)) % (popcnt - 1); count = 1; while (t) { t = t % (__builtin_popcountll(t)); count++; } } ans[i] = count; } reverse(all(ans)); for (int x : ans) cout << x << "\n"; } signed main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; int T = 0; while (t--) { T++; // cout<<"Scenario #"<<T<<":\n"; solve(); if (t) cout << "\n"; } return 0; } /* 6 4 1 3 4 5 6 2 */
replace
66
68
66
89
0
p02609
C++
Runtime Error
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = int; #define INF 0x6fffffff #define INFL 0x6fffffffffffffffLL int main() { ll a, b, c, p, pc, np, h, i, j, k, l, m, n, y; ll ans = 0; string x, xx; cin >> n >> x; vector<ll> pcm(n), pcp(n); pc = 0; for (i = 0; i < n; i++) if (x[i] == '1') pc++; if (pc > 1) pcm[n - 1] = 1 % (pc - 1); else pcm[n - 1] = 0; pcp[n - 1] = 1 % (pc + 1); for (i = n - 2; i >= 0; i--) { if (pc > 1) pcm[i] = (pcm[i + 1] * 2) % (pc - 1); else pcm[i] = 0; pcp[i] = (pcp[i + 1] * 2) % (pc + 1); } a = b = 0; for (i = n - 1; i >= 0; i--) { if (x[i] == '1') { a += pcm[i]; a %= pc - 1; b += pcp[i]; b %= pc + 1; } } // printf("pc=%d a=%d b=%d\n",pc , a , b); for (i = 0; i < n; i++) { ans = 0; if (x[i] == '0') { p = pc + 1; np = (b + pcp[i]) % p; } else { p = pc - 1; if (p != 0) np = (a + p - pcm[i]) % p; else np = 0; } if (p != 0) ans++; // printf("p=%d np=%d\n",p,np); while (np != 0) { ans++; p = __builtin_popcount(np); np = np % p; } cout << ans << endl; } return 0; }
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = int; #define INF 0x6fffffff #define INFL 0x6fffffffffffffffLL int main() { ll a, b, c, p, pc, np, h, i, j, k, l, m, n, y; ll ans = 0; string x, xx; cin >> n >> x; vector<ll> pcm(n), pcp(n); pc = 0; for (i = 0; i < n; i++) if (x[i] == '1') pc++; if (pc > 1) pcm[n - 1] = 1 % (pc - 1); else pcm[n - 1] = 0; pcp[n - 1] = 1 % (pc + 1); for (i = n - 2; i >= 0; i--) { if (pc > 1) pcm[i] = (pcm[i + 1] * 2) % (pc - 1); else pcm[i] = 0; pcp[i] = (pcp[i + 1] * 2) % (pc + 1); } a = b = 0; for (i = n - 1; i >= 0; i--) { if (x[i] == '1') { a += pcm[i]; if (pc > 1) a %= pc - 1; b += pcp[i]; b %= pc + 1; } } // printf("pc=%d a=%d b=%d\n",pc , a , b); for (i = 0; i < n; i++) { ans = 0; if (x[i] == '0') { p = pc + 1; np = (b + pcp[i]) % p; } else { p = pc - 1; if (p != 0) np = (a + p - pcm[i]) % p; else np = 0; } if (p != 0) ans++; // printf("p=%d np=%d\n",p,np); while (np != 0) { ans++; p = __builtin_popcount(np); np = np % p; } cout << ans << endl; } return 0; }
replace
33
34
33
35
0
p02609
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define uniq(v) (v).erase(unique(all(v)), (v).end()) #define sz(x) (int)((x).size()) #define fr first #define sc second #define pii pair<int, int> #define rep(i, a, b) for (int i = a; i < b; i++) #define mem1(a) memset(a, -1, sizeof(a)) #define mem0(a) memset(a, 0, sizeof(a)) #define ppc __builtin_popcount #define ppcll __builtin_popcountll template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &a) { in >> a.fr >> a.sc; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> a) { out << a.fr << " " << a.sc; return out; } template <typename T, typename T1> T amax(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } const long long INF = 1e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; const int N = 2e5 + 5; int pw(int a, int p = M - 2, int MOD = M) { int result = 1; while (p > 0) { if (p & 1) result = a * result % MOD; a = a * a % MOD; p >>= 1; } return result; } int f(int n) { if (n == 0) return 0; int pc = ppc(n); return 1 + f(n % pc); } int rem[N]; int x[N]; void solve() { int n; string s; cin >> n >> s; int pc = 0; rep(i, 0, n) { x[i] = s.back() - '0'; s.ppb(); pc += x[i]; } rep(p, pc - 1, pc + 2) { if (p <= 0) continue; int ans = 0; rep(i, 0, n) { if (x[i]) ans += pw(2, i, p); ans %= p; } rem[p] = ans; } for (int i = n - 1; i >= 0; i--) { if (x[i]) { if (pc == 1) { cout << 0 << "\n"; } int k = (rem[pc - 1] - pw(2, i, pc - 1) + pc - 1) % (pc - 1); cout << 1 + f(k) << "\n"; } else { int k = (rem[pc + 1] + pw(2, i, pc + 1)) % (pc + 1); cout << 1 + f(k) << "\n"; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #ifdef SIEVE sieve(); #endif #ifdef NCR init(); #endif int t = 1; // cin>>t; while (t--) solve(); return 0; }
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define uniq(v) (v).erase(unique(all(v)), (v).end()) #define sz(x) (int)((x).size()) #define fr first #define sc second #define pii pair<int, int> #define rep(i, a, b) for (int i = a; i < b; i++) #define mem1(a) memset(a, -1, sizeof(a)) #define mem0(a) memset(a, 0, sizeof(a)) #define ppc __builtin_popcount #define ppcll __builtin_popcountll template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &a) { in >> a.fr >> a.sc; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> a) { out << a.fr << " " << a.sc; return out; } template <typename T, typename T1> T amax(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } const long long INF = 1e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; const int N = 2e5 + 5; int pw(int a, int p = M - 2, int MOD = M) { int result = 1; while (p > 0) { if (p & 1) result = a * result % MOD; a = a * a % MOD; p >>= 1; } return result; } int f(int n) { if (n == 0) return 0; int pc = ppc(n); return 1 + f(n % pc); } int rem[N]; int x[N]; void solve() { int n; string s; cin >> n >> s; int pc = 0; rep(i, 0, n) { x[i] = s.back() - '0'; s.ppb(); pc += x[i]; } rep(p, pc - 1, pc + 2) { if (p <= 0) continue; int ans = 0; rep(i, 0, n) { if (x[i]) ans += pw(2, i, p); ans %= p; } rem[p] = ans; } for (int i = n - 1; i >= 0; i--) { if (x[i]) { if (pc == 1) { cout << 0 << "\n"; continue; } int k = (rem[pc - 1] - pw(2, i, pc - 1) + pc - 1) % (pc - 1); cout << 1 + f(k) << "\n"; } else { int k = (rem[pc + 1] + pw(2, i, pc + 1)) % (pc + 1); cout << 1 + f(k) << "\n"; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #ifdef SIEVE sieve(); #endif #ifdef NCR init(); #endif int t = 1; // cin>>t; while (t--) solve(); return 0; }
insert
96
96
96
97
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int popcount(int x) { return __builtin_popcount(x); } // 再帰関数によって操作回数をカウント int f(int x) { if (x == 0) return 0; return f(x % popcount(x)) + 1; } int main() { int n; cin >> n; string s; cin >> s; vector<int> x(n); rep(i, n) x[i] = s[i] - '0'; int pc = 0; rep(i, n) pc += x[i]; vector<int> ans(n); // popcountが増える場合と減る場合で分けて考える rep(b, 2) { // 新しいpopcount int npc = pc; if (b == 0) npc++; else npc--; // npcが0以下の場合の例外処理 // if (npc <= 0) continue; // 元のXに対して操作を行った結果を保持 int r0 = 0; rep(i, n) { r0 = (r0 * 2) % npc; r0 += x[i]; } // 下の桁から順にXiに対する操作結果を調べる. // 各桁ごとにk=2^n%npcを計算してr0と組み合わせて答えを算出. int k = 1; for (int i = n - 1; i >= 0; --i) { if (x[i] == b) { int r = r0; if (b == 0) r = (r + k) % npc; else r = (r - k + npc) % npc; ans[i] = f(r) + 1; } k = (k * 2) % npc; } } rep(i, n) cout << ans[i] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int popcount(int x) { return __builtin_popcount(x); } // 再帰関数によって操作回数をカウント int f(int x) { if (x == 0) return 0; return f(x % popcount(x)) + 1; } int main() { int n; cin >> n; string s; cin >> s; vector<int> x(n); rep(i, n) x[i] = s[i] - '0'; int pc = 0; rep(i, n) pc += x[i]; vector<int> ans(n); // popcountが増える場合と減る場合で分けて考える rep(b, 2) { // 新しいpopcount int npc = pc; if (b == 0) npc++; else npc--; // npcが0以下の場合の例外処理 if (npc <= 0) continue; // 元のXに対して操作を行った結果を保持 int r0 = 0; rep(i, n) { r0 = (r0 * 2) % npc; r0 += x[i]; } // 下の桁から順にXiに対する操作結果を調べる. // 各桁ごとにk=2^n%npcを計算してr0と組み合わせて答えを算出. int k = 1; for (int i = n - 1; i >= 0; --i) { if (x[i] == b) { int r = r0; if (b == 0) r = (r + k) % npc; else r = (r - k + npc) % npc; ans[i] = f(r) + 1; } k = (k * 2) % npc; } } rep(i, n) cout << ans[i] << endl; }
replace
34
35
34
36
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #define int long long using namespace std; constexpr int mod = 1e9 + 7; int f(int x) { for (int ans = 0;; x %= __builtin_popcount(x), ans++) { if (x == 0) return ans; } } int a[200000], b[200000]; signed main() { int n; string x; cin >> n >> x; int popx = count(x.begin(), x.end(), '1'); if (popx == 1) { if (x.back() == '1') { for (int i = 0; i < n - 1; i++) cout << 2 << endl; cout << 0 << endl; } else { for (int i = 0; i < n - 1; i++) cout << (x[i] == '1' ? 0 : 1) << endl; cout << 2 << endl; } } a[n - 1] = b[n - 1] = 1; for (int i = n - 2; i >= 0; i--) { a[i] = a[i + 1] * 2 % (popx + 1); b[i] = b[i + 1] * 2 % (popx - 1); } int aa = 0, bb = 0; for (int i = 0; i < n; i++) { if (x[i] == '1') { (aa += a[i]) %= popx + 1; (bb += b[i]) %= popx - 1; } } for (int i = 0; i < n; i++) { if (x[i] == '1') cout << f((bb - b[i] + popx - 1) % (popx - 1)) + 1 << endl; else cout << f((aa + a[i]) % (popx + 1)) + 1 << endl; } }
#include <bits/stdc++.h> #define int long long using namespace std; constexpr int mod = 1e9 + 7; int f(int x) { for (int ans = 0;; x %= __builtin_popcount(x), ans++) { if (x == 0) return ans; } } int a[200000], b[200000]; signed main() { int n; string x; cin >> n >> x; int popx = count(x.begin(), x.end(), '1'); if (popx == 1) { if (x.back() == '1') { for (int i = 0; i < n - 1; i++) cout << 2 << endl; cout << 0 << endl; } else { for (int i = 0; i < n - 1; i++) cout << (x[i] == '1' ? 0 : 1) << endl; cout << 2 << endl; } return 0; } a[n - 1] = b[n - 1] = 1; for (int i = n - 2; i >= 0; i--) { a[i] = a[i + 1] * 2 % (popx + 1); b[i] = b[i + 1] * 2 % (popx - 1); } int aa = 0, bb = 0; for (int i = 0; i < n; i++) { if (x[i] == '1') { (aa += a[i]) %= popx + 1; (bb += b[i]) %= popx - 1; } } for (int i = 0; i < n; i++) { if (x[i] == '1') cout << f((bb - b[i] + popx - 1) % (popx - 1)) + 1 << endl; else cout << f((aa + a[i]) % (popx + 1)) + 1 << endl; } }
insert
26
26
26
27
0
p02609
C++
Runtime Error
#include <bits/stdc++.h> #include <cstdint> #include <vector> #define FOR(i, l, r) for (int i = (l); i < (r); ++i) #define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n - 1, 0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e9; const int mod = 1e9 + 7; #define ll long long int p[MX][2]; int a[MX][2]; signed main() { int n; cin >> n; string s; cin >> s; int pp = 0; rep(i, n) { if (s[i] == '1') pp++; } int now = 1; int tm = s[n - 1] - '0'; if (pp > 1) p[n - 1][0] = tm % (pp - 1); p[n - 1][1] = tm % (pp + 1); // cout << tm%(pp-1)<<p[n-1][1] << endl; int k = 1; int kk = 1; a[n - 1][0] = k; a[n - 1][1] = kk; RFOR(i, n - 2, 0) { tm = s[i] - '0'; k *= 2; kk *= 2; if (pp > 1) k %= (pp - 1); kk %= (pp + 1); a[i][0] = k; a[i][1] = kk; if (pp > 1) p[i][0] = (tm * k + p[i + 1][0]) % (pp - 1); p[i][1] = (tm * kk + p[i + 1][1]) % (pp + 1); // cout << i<<" "<<p[i][1] << endl; } // cout << pp << endl; rep(i, n) { int ans = 1; int y = 0; if (s[i] == '0') { y = p[0][1] + a[i][1]; y %= (pp + 1); // cout << "y "<<p[0][1]<<" + "<<a[i][1]<<" "<<y << endl; } else { y = p[0][0] - a[i][0]; y %= pp - 1; if (y < 0) y += pp - 1; // cout << "y "<<p[0][0]<<" - "<<a[i][0]<<" "<<y << endl; } while (y > 0) { int cy = y; int ppp = 0; while (cy > 0) { ppp += cy % 2; cy /= 2; } y = y % ppp; ans++; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> #include <cstdint> #include <vector> #define FOR(i, l, r) for (int i = (l); i < (r); ++i) #define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, n - 1, 0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e9; const int mod = 1e9 + 7; #define ll long long int p[MX][2]; int a[MX][2]; signed main() { int n; cin >> n; string s; cin >> s; int pp = 0; rep(i, n) { if (s[i] == '1') pp++; } int now = 1; int tm = s[n - 1] - '0'; if (pp > 1) p[n - 1][0] = tm % (pp - 1); p[n - 1][1] = tm % (pp + 1); // cout << tm%(pp-1)<<p[n-1][1] << endl; int k = 1; int kk = 1; a[n - 1][0] = k; a[n - 1][1] = kk; RFOR(i, n - 2, 0) { tm = s[i] - '0'; k *= 2; kk *= 2; if (pp > 1) k %= (pp - 1); kk %= (pp + 1); a[i][0] = k; a[i][1] = kk; if (pp > 1) p[i][0] = (tm * k + p[i + 1][0]) % (pp - 1); p[i][1] = (tm * kk + p[i + 1][1]) % (pp + 1); // cout << i<<" "<<p[i][1] << endl; } // cout << pp << endl; rep(i, n) { int ans = 1; int y = 0; if (s[i] == '0') { y = p[0][1] + a[i][1]; y %= (pp + 1); // cout << "y "<<p[0][1]<<" + "<<a[i][1]<<" "<<y << endl; } else { if (pp > 1) { y = p[0][0] - a[i][0]; y %= pp - 1; if (y < 0) y += pp - 1; } else { ans = 0; } // cout << "y "<<p[0][0]<<" - "<<a[i][0]<<" "<<y << endl; } while (y > 0) { int cy = y; int ppp = 0; while (cy > 0) { ppp += cy % 2; cy /= 2; } y = y % ppp; ans++; } cout << ans << endl; } return 0; }
replace
60
64
60
68
0