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
p02689
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int H[11000]; bool good[11000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; for (int i = 0; i < N; i++) cin >> H[i]; fill(good, good + N, 1); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--, b--; if (H[a] <= H[b]) good[a] = 0; if (H[a] >= H[b]) good[b] = 0; } int cnt = 0; for (int i = 0; i < N; i++) if (good[i]) cnt++; cout << cnt << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int H[110000]; bool good[110000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; for (int i = 0; i < N; i++) cin >> H[i]; fill(good, good + N, 1); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--, b--; if (H[a] <= H[b]) good[a] = 0; if (H[a] >= H[b]) good[b] = 0; } int cnt = 0; for (int i = 0; i < N; i++) if (good[i]) cnt++; cout << cnt << '\n'; return 0; }
replace
5
7
5
7
0
p02689
C++
Time Limit Exceeded
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int, vector<int>, greater<int>> #define PriP \ priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(), (a).end() #define elif else if int low(V<int> &a, int b) { auto c = lower_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } int upp(V<int> &a, int b) { auto c = upper_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } int gcm(int a, int b) { if (a % b == 0) return b; return gcm(b, a % b); } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a) + 1; i += 2) { if (a % i == 0) return false; } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n, int r) { int a = 1; r = min(r, n - r); for (int i = n; i > n - r; i--) { a *= i; a /= n - i + 1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a) { int b = 1; fo(i, a) b *= i + 1; return b; } int nPr(int a, int b) { if (a < b) return 0; if (b == 0) return 1; int c = 1; for (int i = a; i > a - b; i--) { c *= i; c %= INF; } return c; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } int lcm(int a, int b) { int c = modinv(gcm(a, b), INF); return ((a * c) % INF) * (b % INF) % INF; } int MOD = INF; int fac[1000010], finv[1000010], inv[1000010]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 int COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool naka(int a, int b, V<V<char>> c) { return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz); } V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}, {-1, -1}, {1, 1}, {1, -1}, {-1, -1}}; int inf = 1000000000000000007; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}; // 最短経路の表 a(全部INFで初期化) // 縦横 x,y // 迷路 f // スタートsx,sy // ゴールgx,gy // 文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a) { V<int> b(a.sz); for (int i = 1, j = 0; i < a.sz; i++) { if (i + b[i - j] < j + b[j]) b[i] = b[i - j]; else { int c = max<int>(0, j + b[j] - i); while (i + c < a.sz && a[c] == a[i + c]) c++; b[i] = c; j = i; } } b[0] = a.sz; return b; } int pow_kai(int a, int b) { int c = 1; while (b > 0) { // bit全部捨てるまで if (b % 2) { // 一番右のbitが1 c = c * a; } a = a * a; b >>= 1; // 全体右に1つシフト } return c; } // 12だったら{(2,2),(3,1)}って返してくれるはず V<P<int, int>> factorize(int n) { V<P<int, int>> res; for (int i = 2; i * i <= n; i++) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; signed main() { int n, m; cin >> n >> m; V<int> h(n); fo(i, n) { cin >> h[i]; } V<P<int, int>> a(m); fo(i, m) { cin >> a[i].fi >> a[i].se; } V<int> ans; for (int i = 0; i < n; i++) { int b = h[i]; int c = 1; for (int j = 0; j < m; j++) { int e = a[j].fi; int d = a[j].se; e--; d--; if (e != i && d != i) continue; if (h[e] == h[d]) { c = 0; break; } else { if (e == i) { if (b <= h[d]) { c = 0; break; } } else { if (b <= h[e]) { c = 0; break; } } } } if (c) ans.pb(b); } cout << ans.sz << endl; }
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int, vector<int>, greater<int>> #define PriP \ priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(), (a).end() #define elif else if int low(V<int> &a, int b) { auto c = lower_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } int upp(V<int> &a, int b) { auto c = upper_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } int gcm(int a, int b) { if (a % b == 0) return b; return gcm(b, a % b); } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a) + 1; i += 2) { if (a % i == 0) return false; } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n, int r) { int a = 1; r = min(r, n - r); for (int i = n; i > n - r; i--) { a *= i; a /= n - i + 1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a) { int b = 1; fo(i, a) b *= i + 1; return b; } int nPr(int a, int b) { if (a < b) return 0; if (b == 0) return 1; int c = 1; for (int i = a; i > a - b; i--) { c *= i; c %= INF; } return c; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } int lcm(int a, int b) { int c = modinv(gcm(a, b), INF); return ((a * c) % INF) * (b % INF) % INF; } int MOD = INF; int fac[1000010], finv[1000010], inv[1000010]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 int COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool naka(int a, int b, V<V<char>> c) { return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz); } V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}, {-1, -1}, {1, 1}, {1, -1}, {-1, -1}}; int inf = 1000000000000000007; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}; // 最短経路の表 a(全部INFで初期化) // 縦横 x,y // 迷路 f // スタートsx,sy // ゴールgx,gy // 文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a) { V<int> b(a.sz); for (int i = 1, j = 0; i < a.sz; i++) { if (i + b[i - j] < j + b[j]) b[i] = b[i - j]; else { int c = max<int>(0, j + b[j] - i); while (i + c < a.sz && a[c] == a[i + c]) c++; b[i] = c; j = i; } } b[0] = a.sz; return b; } int pow_kai(int a, int b) { int c = 1; while (b > 0) { // bit全部捨てるまで if (b % 2) { // 一番右のbitが1 c = c * a; } a = a * a; b >>= 1; // 全体右に1つシフト } return c; } // 12だったら{(2,2),(3,1)}って返してくれるはず V<P<int, int>> factorize(int n) { V<P<int, int>> res; for (int i = 2; i * i <= n; i++) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; signed main() { int n, m; cin >> n >> m; V<int> h(n); fo(i, n) { cin >> h[i]; } V<P<int, int>> a(m); fo(i, m) { cin >> a[i].fi >> a[i].se; } V<int> s; fo(i, m) { int b = h[a[i].fi - 1]; int c = h[a[i].se - 1]; if (b == c) { s.pb(a[i].fi); s.pb(a[i].se); } if (b > c) s.pb(a[i].se); if (b < c) s.pb(a[i].fi); } Sort(s); uni(s); cout << n - s.sz << endl; }
replace
371
404
371
388
TLE
p02689
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define Canuc80k \ cin.tie(0); \ cout.tie(0); #define I_am ios_base::sync_with_stdio(false); #define REP(i, a, b) for (int i = a; i < b; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define FORD(i, a, b) for (int i = a; i >= b; i--) const int N = 1e6 + 1; const int M = 1e9 + 7; string str; pair<int, int> a[N]; int n, m, h[N], cnt = 0; bool pp[N]; int main() { I_am Canuc80k; cin >> n >> m; FOR(i, 1, n) { cin >> h[i]; pp[i] = true; } FOR(i, 1, m) cin >> a[i].first >> a[i].second; sort(a + 1, a + m + 1); FOR(i, 1, m) { int now = h[a[i].first]; bool ok = false; FOR(j, i, m) { if (a[j].first != a[i].first || j == m) { if (h[a[j].second] >= now) pp[a[i].second] = false; if (h[a[j].second] <= now) pp[a[j].second] = false; i = j - 1; break; } else { if (h[a[j].second] >= now) pp[a[i].second] = false; if (h[a[j].second] <= now) pp[a[j].second] = false; } } } FOR(i, 1, n) if (pp[i]) cnt++; cout << cnt; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define Canuc80k \ cin.tie(0); \ cout.tie(0); #define I_am ios_base::sync_with_stdio(false); #define REP(i, a, b) for (int i = a; i < b; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define FORD(i, a, b) for (int i = a; i >= b; i--) const int N = 1e6 + 1; const int M = 1e9 + 7; string str; pair<int, int> a[N]; int n, m, h[N], cnt = 0; bool pp[N]; int main() { I_am Canuc80k; cin >> n >> m; FOR(i, 1, n) { cin >> h[i]; pp[i] = true; } FOR(i, 1, m) cin >> a[i].first >> a[i].second; sort(a + 1, a + m + 1); FOR(j, 1, m) { if (h[a[j].second] >= h[a[j].first]) pp[a[j].first] = false; if (h[a[j].second] <= h[a[j].first]) pp[a[j].second] = false; } FOR(i, 1, n) if (pp[i]) cnt++; cout << cnt; }
replace
35
54
35
40
TLE
p02689
C++
Runtime Error
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define ll long long int #define py printf("Yes\n") #define pn printf("No\n") #define in cin >> using namespace std; int main() { int n, m, h[n], ma[n]; in n >> m; for (int i = 1; i <= n; i++) { in h[i]; ma[i] = 0; } for (int i = 0; i < m; i++) { int a, b; in a >> b; ma[a] = max(ma[a], h[b]); ma[b] = max(ma[b], h[a]); } int ans = 0; for (int i = 1; i <= n; i++) { ans += h[i] > ma[i]; } cout << ans << endl; }
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define ll long long int #define py printf("Yes\n") #define pn printf("No\n") #define in cin >> using namespace std; int main() { int n, m, h[100000], ma[100000]; in n >> m; for (int i = 1; i <= n; i++) { in h[i]; ma[i] = 0; } for (int i = 0; i < m; i++) { int a, b; in a >> b; ma[a] = max(ma[a], h[b]); ma[b] = max(ma[b], h[a]); } int ans = 0; for (int i = 1; i <= n; i++) { ans += h[i] > ma[i]; } cout << ans << endl; }
replace
9
10
9
10
-11
p02689
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> /* H(N), */ A(M), B(M); int H[6]; for (int i = 0; i < N; ++i) { cin >> H[i]; } for (int i = 0; i < M; ++i) { cin >> A[i] >> B[i]; } vector<vector<int>> g(N); for (int i = 0; i < M; ++i) { g[A[i] - 1].push_back(B[i] - 1), g[B[i] - 1].push_back(A[i] - 1); } int ans = 0; for (int i = 0; i < N; ++i) { bool is_good = true; for (size_t j = 0; j < g[i].size(); ++j) { if (H[i] <= H[g[i][j]]) { is_good = false; } } if (is_good) { ++ans; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> H(N), A(M), B(M); for (int i = 0; i < N; ++i) { cin >> H[i]; } for (int i = 0; i < M; ++i) { cin >> A[i] >> B[i]; } vector<vector<int>> g(N); for (int i = 0; i < M; ++i) { g[A[i] - 1].push_back(B[i] - 1), g[B[i] - 1].push_back(A[i] - 1); } int ans = 0; for (int i = 0; i < N; ++i) { bool is_good = true; for (size_t j = 0; j < g[i].size(); ++j) { if (H[i] <= H[g[i][j]]) { is_good = false; } } if (is_good) { ++ans; } } cout << ans << endl; }
replace
6
8
6
7
0
p02689
C++
Runtime Error
#include <array> #include <iostream> using namespace std; int main(void) { std::array<bool, 10> is_good_list; std::array<int, 10> height_list; int n, m; cin >> n; cin >> m; is_good_list.fill(true); // 展望台の高さを登録 for (int s = 0; s < n; s++) { int h; cin >> h; height_list[s] = h; } for (int i = 0; i < m; i++) { int a, b; cin >> a; cin >> b; a--; b--; if (height_list[a] <= height_list[b]) { is_good_list[a] = false; } if (height_list[a] >= height_list[b]) { is_good_list[b] = false; } } int good_num = 0; for (int i = 0; i < n; i++) { if (is_good_list[i]) { good_num++; } } cout << good_num; }
#include <array> #include <iostream> using namespace std; int main(void) { std::array<bool, 100000> is_good_list; std::array<int, 100000> height_list; int n, m; cin >> n; cin >> m; is_good_list.fill(true); // 展望台の高さを登録 for (int s = 0; s < n; s++) { int h; cin >> h; height_list[s] = h; } for (int i = 0; i < m; i++) { int a, b; cin >> a; cin >> b; a--; b--; if (height_list[a] <= height_list[b]) { is_good_list[a] = false; } if (height_list[a] >= height_list[b]) { is_good_list[b] = false; } } int good_num = 0; for (int i = 0; i < n; i++) { if (is_good_list[i]) { good_num++; } } cout << good_num; }
replace
6
8
6
8
0
p02689
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long N, M; cin >> N >> M; vector<long long> H(N); for (long long i = 0; i < N; i++) { cin >> H.at(i); } vector<long long> A(M), B(M); for (long long i = 0; i < M; i++) { cin >> A.at(i) >> B.at(i); } vector<long long> ans(N, 0); for (long long i = 0; i < M; i++) { if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1)) { ans.at(B.at(i) - 1) = 1; } if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)) { ans.at(A.at(i) - 1) = 1; } if (H.at(A.at(i)) == H.at(B.at(i))) { ans.at(A.at(i) - 1) = 1; ans.at(B.at(i) - 1) = 1; } } long long X = 0; for (long long i = 0; i < N; i++) { if (ans.at(i) == 1) { X++; } } cout << N - X << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long N, M; cin >> N >> M; vector<long long> H(N); for (long long i = 0; i < N; i++) { cin >> H.at(i); } vector<long long> A(M), B(M); for (long long i = 0; i < M; i++) { cin >> A.at(i) >> B.at(i); } vector<long long> ans(N, 0); for (long long i = 0; i < M; i++) { if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1)) { ans.at(B.at(i) - 1) = 1; } if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)) { ans.at(A.at(i) - 1) = 1; } if (H.at(A.at(i) - 1) == H.at(B.at(i) - 1)) { ans.at(A.at(i) - 1) = 1; ans.at(B.at(i) - 1) = 1; } } long long X = 0; for (long long i = 0; i < N; i++) { if (ans.at(i) == 1) { X++; } } cout << N - X << endl; }
replace
23
24
23
24
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
p02690
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; typedef pair<int, int> P; int main(void) { ll x; cin >> x; ll y; for (int a = -120; a <= x; a++) { for (int b = -120; b <= x; b++) { ll ans = pow(a, 5) - pow(b, 5); if (x == ans) { cout << a << " " << b << 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; typedef pair<int, int> P; int main(void) { ll x; cin >> x; ll y; for (int a = -120; a <= 120; a++) { for (int b = -120; b <= 120; b++) { ll ans = pow(a, 5) - pow(b, 5); if (x == ans) { cout << a << " " << b << endl; return 0; } } } }
replace
10
12
10
12
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define INF (1 << 30) #define EPS 1e-10 #define MOD 1000000007 #define rep(i, n) FOR(i, 0, n) #define FOR(i, x, n) for (int i = (x); i < (n); ++i) #define all(v) (v).begin(), (v).end() using ll = long long; template <class T> void chmax(T &a, T b) { a > b ?: a = b; } template <class T> void chmin(T &a, T b) { a < b ?: a = b; } ll x; void f(ll c) { for (ll b = -1e6; b <= 1e6; ++b) { ll a = b + c; if (pow(a, 5LL) - pow(b, 5LL) == x) { cout << a << " " << b << endl; exit(0); } } } int main() { cin >> x; for (ll i = 1; i * i <= x; ++i) { if (x % i == 0) { f(i); if (x / i != i) f(x / i); } } return 0; }
#include <bits/stdc++.h> using namespace std; #define INF (1 << 30) #define EPS 1e-10 #define MOD 1000000007 #define rep(i, n) FOR(i, 0, n) #define FOR(i, x, n) for (int i = (x); i < (n); ++i) #define all(v) (v).begin(), (v).end() using ll = long long; template <class T> void chmax(T &a, T b) { a > b ?: a = b; } template <class T> void chmin(T &a, T b) { a < b ?: a = b; } ll x; void f(ll c) { for (ll b = -1e4; b <= 1e4; ++b) { ll a = b + c; if (pow(a, 5LL) - pow(b, 5LL) == x) { cout << a << " " << b << endl; exit(0); } } } int main() { cin >> x; for (ll i = 1; i * i <= x; ++i) { if (x % i == 0) { f(i); if (x / i != i) f(x / i); } } return 0; }
replace
20
21
20
21
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1000000007; using Graph = vector<vector<int>>; signed main() { int X; cin >> X; for (int i = 1;; i++) { int A = i * i * i * i * i; int sa = abs(X - A); for (int j = 0; j < 5; j++) sa = sqrt(sa); if (pow(sa, 5) != abs(X - A)) continue; if (X - A > 0) cout << i << " " << -1 * sa << endl; else cout << i << " " << sa << endl; return 0; } }
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1000000007; using Graph = vector<vector<int>>; signed main() { int X; cin >> X; for (int A = -150; A <= 150; A++) { for (int B = -150; B <= 150; B++) { if (pow(A, 5) - pow(B, 5) == X) { cout << A << " " << B << endl; return 0; } } } }
replace
10
22
10
17
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1e9 + 7; int main() { ll X; cin >> X; if (X == 1) { cout << 0 << " " << -1 << endl; return 0; } for (ll i = 1; i < X; i++) { if (X % i == 0) { ll X1 = i; ll X2 = X / i; for (int b = -X1; b <= X1; b++) { ll a = X1 + b; ll ans = pow(X1 + b, 4) + pow(X1 + b, 3) * b + pow(X1 + b, 2) * b * b + pow(X1 + b, 1) * b * b * b + b * b * b * b; // cout << a << " " << b <<" " << ans<< endl; if (X2 == ans) { cout << a << " " << b << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1e9 + 7; int main() { ll X; cin >> X; for (int i = -1000; i <= 1000; i++) { for (int j = -1000; j <= 1000; j++) { if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } } }
replace
8
25
8
13
TLE
p02690
C++
Time Limit Exceeded
// 2020-05-03 21:21:37 #include <bits/stdc++.h> using namespace std; using ll = long long; ll f(ll x) { return x * x * x * x * x; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll X; cin >> X; while (true) { ll A = -1000; for (ll B = -1000; B < 1000; B++) { if (f(A) - f(B) == X) { cout << A << " " << B << endl; return 0; } } A++; } }
// 2020-05-03 21:21:37 #include <bits/stdc++.h> using namespace std; using ll = long long; ll f(ll x) { return x * x * x * x * x; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll X; cin >> X; int A = 1; while (f(A) - f(A - 1) < 1000000000) { for (int B = -200; B < 200; B++) { if (f(A) - f(B) == X) { cout << A << " " << B << endl; return 0; } } A++; } }
replace
11
14
11
14
TLE
p02690
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 P = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); ll x; cin >> x; for (ll i = 0; i < 100000; ++i) { for (ll j = 0; j < 100000; ++j) { if (i * i * i * i * i + j * j * j * j * j == x) { cout << i << " " << 0 - j << endl; return 0; } } } 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 P = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); ll x; cin >> x; map<ll, ll> mp; mp[0] = 0; for (ll i = 1; i * i * i * i * i <= 100 * x; i++) { ll cur = i * i * i * i * i; mp[cur] = i; mp[-cur] = -i; if (mp.count(cur - x) != 0) { cout << i << " " << mp[cur - x] << endl; } } return 0; }
replace
11
17
11
19
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using ll = long long; #define rep(i, n) for (ll i = 1; i <= (n); i++) #define all(x) (x).begin(), (x).end() using namespace std; using Graph = vector<vector<int>>; int main() { ll x; cin >> x; ll a, b; ll y = sqrt(x); // cout <<y<<endl; rep(i, y) { if (x % i == 0) { for (ll j = 0; j <= pow(x, 0.8); j++) { // cout<<pow(x,0.2)<<endl; if (j * j * j * j + j * j * j * (j - i) + j * j * (j - i) * (j - i) + j * (j - i) * (j - i) * (j - i) + (j - i) * (j - i) * (j - i) * (j - i) == x / i) { a = j; b = j - i; break; } } if (!(a == 0 && b == 0)) break; } } cout << a << " " << b << endl; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using ll = long long; #define rep(i, n) for (ll i = 1; i <= (n); i++) #define all(x) (x).begin(), (x).end() using namespace std; using Graph = vector<vector<int>>; int main() { ll x; cin >> x; ll a, b; ll y = sqrt(x); // cout <<y<<endl; rep(i, y) { if (x % i == 0) { for (ll j = 0; j <= pow(x, 0.6); j++) { // cout<<pow(x,0.2)<<endl; if (j * j * j * j + j * j * j * (j - i) + j * j * (j - i) * (j - i) + j * (j - i) * (j - i) * (j - i) + (j - i) * (j - i) * (j - i) * (j - i) == x / i) { a = j; b = j - i; break; } } if (!(a == 0 && b == 0)) break; } } cout << a << " " << b << endl; }
replace
18
19
18
19
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { int x; cin >> x; int a = 0, b = 0; int temp = 0; while (1) { while (pow(a, 5.0) < x) { a++; } if (pow(a, 5.0) == x) { cout << a << " " << b << endl; return 0; } a--; temp = pow(a, 5.0); int val = 0; while ((val = temp - pow(b, 5.0)) != x && val <= x) { b--; } if (temp - pow(b, 5.0) == x) { cout << a << " " << b << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int x; cin >> x; int a = 0, b = 0; for (a = -1000; a <= 1000; a++) { for (b = -1000; b <= 1000; b++) { if (pow(a, 5.0) - pow(b, 5.0) == x) { cout << a << " " << b << endl; return 0; } } } return 0; }
replace
6
24
6
12
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define P pair<ll, ll> #define mk make_pair using namespace std; const int N = 55; ll a[N]; map<ll, P> mp; int main() { for (ll i = 0; i <= 1000; i++) { ll y = i; for (ll x = 1; x <= 4; x++) { y = y * i; } a[i] = y; } for (int i = 0; i <= 1000; i++) { for (int j = 0; j <= 1000; j++) { mp[a[i] - a[j]] = mk(i, j); mp[a[i] + a[j]] = mk(i, -j); } } ll x; cin >> x; cout << mp[x].first << ' ' << mp[x].second << '\n'; return 0; }
#include <bits/stdc++.h> #define ll long long #define P pair<ll, ll> #define mk make_pair using namespace std; const int N = 10005; ll a[N]; map<ll, P> mp; int main() { for (ll i = 0; i <= 1000; i++) { ll y = i; for (ll x = 1; x <= 4; x++) { y = y * i; } a[i] = y; } for (int i = 0; i <= 1000; i++) { for (int j = 0; j <= 1000; j++) { mp[a[i] - a[j]] = mk(i, j); mp[a[i] + a[j]] = mk(i, -j); } } ll x; cin >> x; cout << mp[x].first << ' ' << mp[x].second << '\n'; return 0; }
replace
5
6
5
6
-11
p02690
C++
Time Limit Exceeded
// int a = stoi(c); 文字列をintへ // 小文字から大文字 // transform(a.begin(), a.end(), a.begin(), ::toupper); // 数値計算 個数以外はdouble // map<キー,値> p は辞書。p[キー] = 値 // map 全探索 // auto begin = p.begin(), end = p.end(); // for (auto it = begin; it != end; it++) {} // mapのキー:it->first mapのバリュー:it->second // 大文字判定 isupper(文字) 小文字判定 islower(文字) // do{}while(next_permutation(ALL(配列))) // 小文字に対応する文字コード:S[i] - 'a' // 文字コード→小文字:(char)(数字+'a') // グラフの距離:隣接行列で扱う // bool型 初期値はTrue // 島渡りの問題:中間ノードに着目 // 背反な事象にちゃんとわける // チェックリストはマップを使う // 数が大きい時の比較はstring型で行う // 全て0になったか調べたい->0になるたびにcntする // 例外処理は最初にする // x = p^m + q^n...の約数の個数:(n+1)*(m+1).... // N!のどの素因数で何回割れるか // ⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和 // パズルの問題->一般化して全探索 // 数が大きい時のせぐふぉはコードテストで試してみる // stack<ll> s; // s.push(要素);s.top();s.pop(); // queue<ll> q; // q.push(要素);q.front();q.pop(); // 同じ作業繰り返す系の問題:収束先を見つける // 関係性は隣接行列で記録 // 過半数:N/2.0で判定 // ある量からある量を引く系の問題:端から定義してやる #include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < N; i++) #define ALL(a) (a).begin(), (a).end() #define ll long long int using namespace std; // 円周率 const double PI = 3.14159265358979323846; // 割るやつ const ll MOD = (pow(10, 9) + 7); // K進数でのNの桁数 ll dig(ll N, ll K) { ll dig = 0; while (N) { dig++; N /= K; } return dig; } // a,bの最大公約数 ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } // a,bの最小公倍数 ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } // 階乗計算 ll f(ll n) { if (n == 0 || n == 1) return 1; else return (n * f(n - 1)); } // Nのd桁目の数 ll dignum(ll N, ll d) { ll x = pow(10, d); N %= x; ll y = pow(10, d - 1); N /= y; return N; } // Nをdで何回割れるか ll divcnt(ll N, ll d) { ll ans = 0; while (1) { if (N % d == 0) { ans++; N /= d; } else break; } return ans; } // 素数判定 bool prime(ll num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } // フィボナッチ数列 vector<ll> memo(pow(10, 6) + 1); ll fibo(ll n) { if (n == 1) return 1; else if (n == 2) return 1; else if (memo[n] != 0) return memo[n]; else return memo[n] = fibo(n - 1) + f(n - 2); } int main() { ll X; cin >> X; ll A, B; for (ll n = 1; n <= sqrt(X) + 1; n++) { for (B = -1; B >= -n; B--) { A = B + n; ll sum = pow(A, 4) + pow(A, 3) * B + pow(A, 2) * pow(B, 2) + A * pow(B, 3) + pow(B, 4); if (X % n == 0 && sum == X / n) { cout << A << " " << B << endl; return 0; } } } }
// int a = stoi(c); 文字列をintへ // 小文字から大文字 // transform(a.begin(), a.end(), a.begin(), ::toupper); // 数値計算 個数以外はdouble // map<キー,値> p は辞書。p[キー] = 値 // map 全探索 // auto begin = p.begin(), end = p.end(); // for (auto it = begin; it != end; it++) {} // mapのキー:it->first mapのバリュー:it->second // 大文字判定 isupper(文字) 小文字判定 islower(文字) // do{}while(next_permutation(ALL(配列))) // 小文字に対応する文字コード:S[i] - 'a' // 文字コード→小文字:(char)(数字+'a') // グラフの距離:隣接行列で扱う // bool型 初期値はTrue // 島渡りの問題:中間ノードに着目 // 背反な事象にちゃんとわける // チェックリストはマップを使う // 数が大きい時の比較はstring型で行う // 全て0になったか調べたい->0になるたびにcntする // 例外処理は最初にする // x = p^m + q^n...の約数の個数:(n+1)*(m+1).... // N!のどの素因数で何回割れるか // ⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和 // パズルの問題->一般化して全探索 // 数が大きい時のせぐふぉはコードテストで試してみる // stack<ll> s; // s.push(要素);s.top();s.pop(); // queue<ll> q; // q.push(要素);q.front();q.pop(); // 同じ作業繰り返す系の問題:収束先を見つける // 関係性は隣接行列で記録 // 過半数:N/2.0で判定 // ある量からある量を引く系の問題:端から定義してやる #include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < N; i++) #define ALL(a) (a).begin(), (a).end() #define ll long long int using namespace std; // 円周率 const double PI = 3.14159265358979323846; // 割るやつ const ll MOD = (pow(10, 9) + 7); // K進数でのNの桁数 ll dig(ll N, ll K) { ll dig = 0; while (N) { dig++; N /= K; } return dig; } // a,bの最大公約数 ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } // a,bの最小公倍数 ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } // 階乗計算 ll f(ll n) { if (n == 0 || n == 1) return 1; else return (n * f(n - 1)); } // Nのd桁目の数 ll dignum(ll N, ll d) { ll x = pow(10, d); N %= x; ll y = pow(10, d - 1); N /= y; return N; } // Nをdで何回割れるか ll divcnt(ll N, ll d) { ll ans = 0; while (1) { if (N % d == 0) { ans++; N /= d; } else break; } return ans; } // 素数判定 bool prime(ll num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } // フィボナッチ数列 vector<ll> memo(pow(10, 6) + 1); ll fibo(ll n) { if (n == 1) return 1; else if (n == 2) return 1; else if (memo[n] != 0) return memo[n]; else return memo[n] = fibo(n - 1) + f(n - 2); } int main() { ll X; cin >> X; ll A, B; ll n = sqrt(X); for (A = -120; A <= 120; A++) { for (B = -120; B <= 120; B++) { if (pow(A, 5) - pow(B, 5) == X) { cout << A << " " << B << endl; return 0; } } } }
replace
132
138
132
136
TLE
p02690
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; inline int gi() { int data = 0, w = 1; char ch = 0; while (!isdigit(ch) && ch != '-') ch = getchar(); if (ch == '-') w = -1, ch = getchar(); while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); return w * data; } long long X; int main() { cin >> X; for (long long a = -500; a <= 500; a++) for (long long b = -500; b <= 500; b++) { long long t1 = a * a * a * a * a, t2 = b * b * b * b * b; if (t1 - t2 == X) return printf("%lld %lld\n", a, b); } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; inline int gi() { int data = 0, w = 1; char ch = 0; while (!isdigit(ch) && ch != '-') ch = getchar(); if (ch == '-') w = -1, ch = getchar(); while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); return w * data; } long long X; int main() { cin >> X; for (long long a = -500; a <= 500; a++) for (long long b = -500; b <= 500; b++) { long long t1 = a * a * a * a * a, t2 = b * b * b * b * b; if (t1 - t2 == X) return printf("%lld %lld\n", a, b) & 0; } return 0; }
replace
27
28
27
28
5
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() // #define print(ele) cout << (ele) << "\n" #define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n" using namespace std; typedef long long ll; typedef vector<int> ivec; typedef vector<string> svec; typedef vector<ll> lvec; const int mod = 1e9 + 7; const ll INF = 1000000000000000000LL; void print() { cout << endl; } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); } int main() { ll x; cin >> x; int a, b; FOR(i, -sqrt(x) - 1, sqrt(x) + 1) { FOR(j, -sqrt(x) - 1, sqrt(x) + 1) { if (pow(i, 5) - pow(j, 5) == x) { print(i, j); return 0; } } } return 0; }
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() // #define print(ele) cout << (ele) << "\n" #define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n" using namespace std; typedef long long ll; typedef vector<int> ivec; typedef vector<string> svec; typedef vector<ll> lvec; const int mod = 1e9 + 7; const ll INF = 1000000000000000000LL; void print() { cout << endl; } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); } int main() { ll x; cin >> x; int y = pow(x, 1.0 / 3.0); FOR(i, -y - 1, y + 1) { FOR(j, -y - 1, y + 1) { if (pow(i, 5) - pow(j, 5) == x) { print(i, j); return 0; } } } return 0; }
replace
31
34
31
34
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define repp(i, n) for (int i = 1; i <= n; i++) #define sort(v) sort((v).begin(), (v).end()) #define riverse(v) reverse((v).begin(), (v).end()) using vi = vector<int>; using vs = vector<string>; const int MOD = 1e9 + 7; int main() { ll X; cin >> X; vector<ll> kouho; ll A = 0; ll B = 0; bool frag = false; for (int i = 1; i < sqrt(X) + 1; i++) { if (X % i == 0) { kouho.push_back(i); kouho.push_back(X / i); } } for (ll x : kouho) { for (ll i = 0 - x / 2; i < 130; i++) { ll y = pow(i + x, 5) - pow(i, 5); if (y == X) { B = i; A = i + x; frag = true; } else if (y > X) break; } if (frag) break; } if (!frag) { for (ll x : kouho) { for (ll i = 0 - x / 2; i >= (-1) * x; i--) { ll y = pow(i + x, 5) - pow(i, 5); if (y == X) { B = i; A = i + x; frag = true; } else if (y > X) break; } if (frag) break; } } cout << A << " " << B << endl; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) for (int i = 0; i < n; i++) #define repp(i, n) for (int i = 1; i <= n; i++) #define sort(v) sort((v).begin(), (v).end()) #define riverse(v) reverse((v).begin(), (v).end()) using vi = vector<int>; using vs = vector<string>; const int MOD = 1e9 + 7; int main() { ll X; cin >> X; vector<ll> kouho; ll A = 0; ll B = 0; bool frag = false; for (int i = 1; i < sqrt(X) + 1; i++) { if (X % i == 0) { kouho.push_back(i); } } for (ll x : kouho) { for (ll i = 0 - x / 2; i < 130; i++) { ll y = pow(i + x, 5) - pow(i, 5); if (y == X) { B = i; A = i + x; frag = true; } else if (y > X) break; } if (frag) break; } if (!frag) { for (ll x : kouho) { for (ll i = 0 - x / 2; i >= (-1) * x; i--) { ll y = pow(i + x, 5) - pow(i, 5); if (y == X) { B = i; A = i + x; frag = true; } else if (y > X) break; } if (frag) break; } } cout << A << " " << B << endl; }
delete
29
30
29
29
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pl; #define all(a) (a).begin(), (a).end() #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for (ll i = 0; i < (n); i++) #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, a, b) for (ll i = (a); i < (b); i++) #define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = (n)-1; i >= 0; i--) #define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--) #define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define SHOW(x) cout << #x << ": " << x << endl; template <class T> ll sumArr(const T &a) { return accumulate(all(a), 0LL); } template <class T> auto minArr(const T &a) { return *min_element(all(a)); } template <class T> auto maxArr(const T &a) { return *max_element(all(a)); } template <class T> void DEBUG_PRINT(T tmp) { cout << tmp << endl; } template <class T1, class... T2> void DEBUG_PRINT(T1 tmp, T2... tmp2) { cout << tmp << " "; DEBUG_PRINT(tmp2...); } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } const ll INF = 1e18, MOD = 1e9 + 7; const int iINF = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int x; cin >> x; rep(i, -5000, 5000) { rep(j, -5000, 5000) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pl; #define all(a) (a).begin(), (a).end() #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for (ll i = 0; i < (n); i++) #define rep2(i, n) for (ll i = 0; i < (n); i++) #define rep3(i, a, b) for (ll i = (a); i < (b); i++) #define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = (n)-1; i >= 0; i--) #define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--) #define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--) #define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c)) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__) #define SHOW(x) cout << #x << ": " << x << endl; template <class T> ll sumArr(const T &a) { return accumulate(all(a), 0LL); } template <class T> auto minArr(const T &a) { return *min_element(all(a)); } template <class T> auto maxArr(const T &a) { return *max_element(all(a)); } template <class T> void DEBUG_PRINT(T tmp) { cout << tmp << endl; } template <class T1, class... T2> void DEBUG_PRINT(T1 tmp, T2... tmp2) { cout << tmp << " "; DEBUG_PRINT(tmp2...); } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } const ll INF = 1e18, MOD = 1e9 + 7; const int iINF = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int x; cin >> x; rep(i, -1000, 1000) { rep(j, -1000, 1000) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
43
45
43
45
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; /// ----------------------------- (Debug) ------------------------------ #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifndef ONLINE_JUDGE eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; vector<char *> tokenizer(const char *args) { char *token = new char[111]; strcpy(token, args); token = strtok(token, ", "); vector<char *> v({token}); while (token = strtok(NULL, ", ")) v.push_back(token); return reverse(v.begin(), v.end()), v; } void debugg(vector<char *> args) { cerr << "\b\b "; } template <typename Head, typename... Tail> void debugg(vector<char *> args, Head H, Tail... T) { debug() << " [" << args.back() << ": " << H << "] "; args.pop_back(); debugg(args, T...); } #define harg(...) #__VA_ARGS__ #ifndef ONLINE_JUDGE #define dbg(...) \ { \ debugg(tokenizer(harg(__VA_ARGS__, \b\t-- > Line)), __VA_ARGS__, \ __LINE__); \ cerr << endl; \ } #else #define dbg(...) \ {} #endif /// ----------------------------------------------------------------------- typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; typedef vector<pi> vpi; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define F first #define S second #define PB push_back #define EB emplace_back #define MP make_pair #define print(x) cout << x << "\n"; #define REP(i, a, b) for (i = a; i <= b; i++) #define RAP(i, a, b) for (i = a; i >= b; i--) #define spa << " " << #define all(x) (x).begin(), (x).end() int mod = 1000000007; const int MX = 0x3f3f3f3f; int main() { IOS; ll x, i, j; cin >> x; if (x == 1) { cout << 0 spa - 1; return 0; } ll p[121]; p[0] = 0; REP(i, 1, 130) p[i] = pow(i, 5); i = 1; j = 2; while (j < 131) { if (p[i] + p[j] < x) j++; else if (p[i] + p[j] > x) i++; else { cout << j << " -" << i; return 0; } } i = 1; j = 2; while (j < 131) { if (p[j] - p[i] > x) i++; else if (p[j] - p[i] < x) j++; else { cout << j << " " << i; return 0; } } // cout<<1 spa 3; return 0; }
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; /// ----------------------------- (Debug) ------------------------------ #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifndef ONLINE_JUDGE eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; vector<char *> tokenizer(const char *args) { char *token = new char[111]; strcpy(token, args); token = strtok(token, ", "); vector<char *> v({token}); while (token = strtok(NULL, ", ")) v.push_back(token); return reverse(v.begin(), v.end()), v; } void debugg(vector<char *> args) { cerr << "\b\b "; } template <typename Head, typename... Tail> void debugg(vector<char *> args, Head H, Tail... T) { debug() << " [" << args.back() << ": " << H << "] "; args.pop_back(); debugg(args, T...); } #define harg(...) #__VA_ARGS__ #ifndef ONLINE_JUDGE #define dbg(...) \ { \ debugg(tokenizer(harg(__VA_ARGS__, \b\t-- > Line)), __VA_ARGS__, \ __LINE__); \ cerr << endl; \ } #else #define dbg(...) \ {} #endif /// ----------------------------------------------------------------------- typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; typedef vector<pi> vpi; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define F first #define S second #define PB push_back #define EB emplace_back #define MP make_pair #define print(x) cout << x << "\n"; #define REP(i, a, b) for (i = a; i <= b; i++) #define RAP(i, a, b) for (i = a; i >= b; i--) #define spa << " " << #define all(x) (x).begin(), (x).end() int mod = 1000000007; const int MX = 0x3f3f3f3f; int main() { IOS; ll x, i, j; cin >> x; REP(i, -120, 120) { REP(j, -120, 120) if (pow(i, 5) - pow(j, 5) == x) { cout << i spa j; return 0; } } // cout<<1 spa 3; return 0; }
replace
94
122
94
98
-6
*** stack smashing detected ***: terminated
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) #define FIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; int fc[100001], in[100001]; int pwmd(int a, int n = mod - 2) { if (!n) return 1; int pt = pwmd(a, n / 2); pt *= pt, pt %= mod; if (n & 1) pt *= a, pt %= mod; return pt; } int nCr(int n, int r) { fc[0] = in[0] = 1; for (int i = 1; i <= 100000; ++i) { fc[i] = (i * fc[i - 1]) % mod; in[i] = pwmd(fc[i]); } int ans = fc[n]; ans = (ans * in[r]) % mod; ans = (ans * in[n - r]) % mod; return ans; } int pow(int a, int b) { int ans = 1; while (b > 0) { if (b & 1) ans *= a; a *= a; b = b >> 1; } return ans; } // vector<pair<int,int>> vec; bool compare(pair<int, int> v1, pair<int, int> v2) { return v1.ss < v2.ss; } vector<int> adj[200005]; int dis[200005]; void dfs1(int par, int u) { for (int x : adj[u]) { if (x == par) continue; dis[x] = dis[u] + 1; dfs1(u, x); } } void dfs(int par, int u, bool *vis) { vis[u] = true; for (int x : adj[u]) { if (x == par) continue; dfs(u, x, vis); vis[x] = true; } } vector<int> vec[100001]; int32_t main() { FIO; int x; cin >> x; int i = 0; int j = 0; for (i = 0; i <= 100000; i++) { for (j = -100; j <= 100; j++) { int temp = pow(i, 5) - pow(j, 5); if (temp == x) { cout << i << " " << j << endl; return 0; } } } }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) #define FIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; int fc[100001], in[100001]; int pwmd(int a, int n = mod - 2) { if (!n) return 1; int pt = pwmd(a, n / 2); pt *= pt, pt %= mod; if (n & 1) pt *= a, pt %= mod; return pt; } int nCr(int n, int r) { fc[0] = in[0] = 1; for (int i = 1; i <= 100000; ++i) { fc[i] = (i * fc[i - 1]) % mod; in[i] = pwmd(fc[i]); } int ans = fc[n]; ans = (ans * in[r]) % mod; ans = (ans * in[n - r]) % mod; return ans; } int pow(int a, int b) { int ans = 1; while (b > 0) { if (b & 1) ans *= a; a *= a; b = b >> 1; } return ans; } // vector<pair<int,int>> vec; bool compare(pair<int, int> v1, pair<int, int> v2) { return v1.ss < v2.ss; } vector<int> adj[200005]; int dis[200005]; void dfs1(int par, int u) { for (int x : adj[u]) { if (x == par) continue; dis[x] = dis[u] + 1; dfs1(u, x); } } void dfs(int par, int u, bool *vis) { vis[u] = true; for (int x : adj[u]) { if (x == par) continue; dfs(u, x, vis); vis[x] = true; } } vector<int> vec[100001]; int32_t main() { FIO; int x; cin >> x; int i = 0; int j = 0; for (i = 0; i <= 100000; i++) { for (j = -100; j <= 10000; j++) { int temp = pow(i, 5) - pow(j, 5); if (temp == x) { cout << i << " " << j << endl; return 0; } } } }
replace
101
102
101
102
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string.h> #include <vector> using namespace std; long long i, j, k, n, m, N, M, ans, X, A, B; double x; int main() { cin >> X; A = 0; B = 0; for (i = 0; i <= X; i++) { N = i * i * i * i * i; if (2 * N >= X) { n = i; break; } } for (i = n; i <= X; i++) { for (j = 0; j <= n; j++) { N = i * i * i * i * i; M = j * j * j * j * j; if (N - M == X) { A = i; B = j; break; } else if (N + M == X) { A = i; B = -j; break; } else if (-N - M == X) { A = -i; B = j; break; } else if (-N + M == X) { A = -i; B = -j; break; } } if (A != 0) break; } cout << A << " " << B; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string.h> #include <vector> using namespace std; long long i, j, k, n, m, N, M, ans, X, A, B; double x; int main() { cin >> X; A = 0; B = 0; for (i = 0; i <= X; i++) { N = i * i * i * i * i; if (2 * N >= X) { n = i; break; } } for (i = n; i <= X; i++) { for (j = 0; j <= i; j++) { N = i * i * i * i * i; M = j * j * j * j * j; if (N - M == X) { A = i; B = j; break; } else if (N + M == X) { A = i; B = -j; break; } else if (-N - M == X) { A = -i; B = j; break; } else if (-N + M == X) { A = -i; B = -j; break; } } if (A != 0) break; } cout << A << " " << B; }
replace
30
31
30
31
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef long double ld; #define pb push_back #define mp make_pair #define fi first #define se second #define INF ll(1e18) #define MOD (ll)1e9 + 7 #define print(a) \ ; \ for (auto x : a) \ cout << x << " "; \ cout << "\n"; #define mset(a) \ ; \ memset(a, 0, sizeof(a)); int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll x; cin >> x; for (ll i = -3000; i <= 3000; i++) { for (ll j = -3000; j <= 3000; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << "\n"; return 0; } } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef long double ld; #define pb push_back #define mp make_pair #define fi first #define se second #define INF ll(1e18) #define MOD (ll)1e9 + 7 #define print(a) \ ; \ for (auto x : a) \ cout << x << " "; \ cout << "\n"; #define mset(a) \ ; \ memset(a, 0, sizeof(a)); int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll x; cin >> x; for (ll i = -118; i <= 119; i++) { for (ll j = -119; j <= 118; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << "\n"; return 0; } } } }
replace
27
29
27
29
TLE
p02690
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target( \ "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #define pie 3.141592653589793238 using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int x; cin >> x; long long map[121]; for (long long i = 0; i < 121; i++) { map[i] = i * i * i * i * i; } for (int i = 0; i < 121; i++) { for (int j = 0; i < 121; j++) { if (map[i] - map[j] == x) { cout << i << " " << j << endl; return 0; } if (map[i] + map[j] == x) { cout << i << " " << j * -1 << endl; return 0; } } } return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target( \ "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #define pie 3.141592653589793238 using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int x; cin >> x; long long map[121]; for (long long i = 0; i < 121; i++) { map[i] = i * i * i * i * i; } for (int i = 0; i < 121; i++) { for (int j = 0; j < 121; j++) { if (map[i] - map[j] == x) { cout << i << " " << j << endl; return 0; } if (map[i] + map[j] == x) { cout << i << " " << j * -1 << endl; return 0; } } } return 0; }
replace
28
29
28
29
-4
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #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 rev(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rev1(i, n) for (int i = (int)(n); i > 0; i--) #define pb push_back #define all(v) ((v).begin(), (v).end()) using ll = long long; using P = pair<int, int>; /* ------------------------------------------------ */ ll fact(int i) { // 階乗 if (i == 0) return 1; return (fact(i - 1)) * i; } ll gcd(ll a, ll b) { // 最大公約数 if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { // 最小公倍数 return a * b / gcd(a, b); } int keta(ll n) { // 桁数を求める if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } ll ketasum(ll n) { // 各桁の和 ll sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } /* ------------------------------------------------ */ int main() { ll x; cin >> x; for (int i = -5000; i <= 5000; i++) { for (int j = -5000; j <= 5000; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << ' ' << j << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #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 rev(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rev1(i, n) for (int i = (int)(n); i > 0; i--) #define pb push_back #define all(v) ((v).begin(), (v).end()) using ll = long long; using P = pair<int, int>; /* ------------------------------------------------ */ ll fact(int i) { // 階乗 if (i == 0) return 1; return (fact(i - 1)) * i; } ll gcd(ll a, ll b) { // 最大公約数 if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { // 最小公倍数 return a * b / gcd(a, b); } int keta(ll n) { // 桁数を求める if (n == 0) return 1; int count = 0; while (n != 0) { n /= 10; count++; } return count; } ll ketasum(ll n) { // 各桁の和 ll sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } /* ------------------------------------------------ */ int main() { ll x; cin >> x; for (int i = -1000; i <= 1000; i++) { for (int j = -1000; j <= 000; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << ' ' << j << endl; return 0; } } } return 0; }
replace
47
49
47
49
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long X; scanf("%lld", &X); for (int i = -1; i <= X; i++) { for (int j = -1; j <= X; j++) { if ((pow(i, 5) - pow(j, 5)) == X) { printf("%d %d\n", i, j); return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { long long X; scanf("%lld", &X); for (int i = -118; i <= 119; i++) { for (int j = -118; j <= 119; j++) { if ((pow(i, 5) - pow(j, 5)) == X) { printf("%d %d\n", i, j); return 0; } } } }
replace
9
11
9
11
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 998244353 #define MAX 10000000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, L, N, M, K, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> X; rep(i, -3500, 3500) rep(j, -3500, 3500) { if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } }
#include <bits/stdc++.h> #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 998244353 #define MAX 10000000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, L, N, M, K, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> X; rep(i, -3000, 3000) { lli A = pow(i, 5); if (A < X) { rep(j, -3000, 0) { if (A - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } } else { rep(j, 0, 3000) { if (A - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } } } }
replace
34
38
34
50
TLE
p02690
C++
Time Limit Exceeded
// Winners don't quit and Quitters don't win #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define mod 998244353 #define MAX 100005 vll adj[MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll x, i, j, a, b; cin >> x; for (i = 0;; ++i) { for (j = -1; j <= i; ++j) { if ((pow(i, 5) - pow(j, 5)) == x) { a = i; b = j; cout << a << " " << b; return 0; } if ((pow(i, 5) - pow(j, 5)) < x) { break; } } } }
// Winners don't quit and Quitters don't win #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define mod 998244353 #define MAX 100005 vll adj[MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll x, i, j, a, b; cin >> x; for (i = 0;; ++i) { for (j = -100; j <= i; ++j) { if ((pow(i, 5) - pow(j, 5)) == x) { a = i; b = j; cout << a << " " << b; return 0; } if ((pow(i, 5) - pow(j, 5)) < x) { break; } } } }
replace
19
20
19
20
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() using ll = long long; string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } 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; } int main() { ll X; cin >> X; ll ans_a = 0; ll ans_b = 0; bool flag = false; for (int i = -X; i <= X; ++i) { for (int k = -X; k <= X; ++k) { // cout << k << " " << i << " " << pow(i, 5) - pow(k, 5) << " " << X << // endl; if (pow(i, 5) - pow(k, 5) == X) { ans_a = i; ans_b = k; flag = true; break; } } if (flag == true) break; } cout << ans_a << " " << ans_b << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() using ll = long long; string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } 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; } int main() { ll X; cin >> X; ll ans_a = 0; ll ans_b = 0; bool flag = false; for (int i = -1000; i <= 1000; ++i) { for (int k = -1000; k <= 1000; ++k) { // cout << k << " " << i << " " << pow(i, 5) - pow(k, 5) << " " << X << // endl; if (pow(i, 5) - pow(k, 5) == X) { ans_a = i; ans_b = k; flag = true; break; } } if (flag == true) break; } cout << ans_a << " " << ans_b << endl; }
replace
30
32
30
32
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define sz(a) (int)a.size() using namespace std; // mod無しバージョン ll pow(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } int main() { ll x; cin >> x; for (ll i = -5000; i <= 5000; i++) { for (ll j = -5000; j <= 5000; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define sz(a) (int)a.size() using namespace std; // mod無しバージョン ll pow(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } int main() { ll x; cin >> x; for (ll i = -1000; i <= 1000; i++) { for (ll j = -1000; j <= 1000; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } }
replace
31
33
31
33
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cfenv> #include <cmath> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define vint vector<int> #define vvint vector<vint> #define P pair<int, int> #define INT_MAX 2147483647 #define MOD 1000000007 using namespace std; typedef long long ll; int main(void) { ll x; cin >> x; ll a, b; ll k = x % 5; ll t = 1; while (true) { for (a = 1; a < 150; a++) { b = a - (5 * t + k); if (abs(b) > abs(a)) { continue; } if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << ' ' << b << endl; return 0; } } t++; } }
#include <algorithm> #include <cfenv> #include <cmath> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define vint vector<int> #define vvint vector<vint> #define P pair<int, int> #define INT_MAX 2147483647 #define MOD 1000000007 using namespace std; typedef long long ll; int main(void) { ll x; cin >> x; ll a, b; ll k = x % 5; ll t = 0; while (true) { for (a = 1; a < 150; a++) { b = a - (5 * t + k); if (abs(b) > abs(a)) { continue; } if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << ' ' << b << endl; return 0; } } t++; } }
replace
28
29
28
29
TLE
p02690
C++
Runtime Error
// C++ 14 #include <bits/stdc++.h> using namespace std; #define ll long long #define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++) int main() { ll x; cin >> x; vector<ll> A; loop(i, 0, 200) { ll f = i; ll y = 1; loop(j, 0, 5) y *= f; if (y > 2000000000) break; A.push_back(y); } int n = A.size(); vector<ll> signs{-1, 1}; loop(i, 0, n) { loop(j, 0, n) { for (auto &&signA : signs) { for (auto &&signB : signs) { if (signA * A[i] - A[j] * signB == x) { cout << signA * i << " " << signB * j << endl; return 0; } } } } } assert(x == 0); return 0; }
// C++ 14 #include <bits/stdc++.h> using namespace std; #define ll long long #define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++) int main() { ll x; cin >> x; for (ll a = -200; a <= 200; a++) { for (ll b = -200; b <= 200; b++) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } assert(x == 0); return 0; }
replace
9
30
9
14
0
p02690
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <unordered_map> // #include"testlib.h" #define endl "\n" #define all(v) v.begin(), v.end() #define allr(s) s.rbegin(), s.rend() #define RT(s) return cout << s, 0 #define watch(x) cout << (#x) << " = " << x << endl #define sz(s) (int)(s.size()) #define PI acos(-1) #define EPS 1e-100 using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; void file() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); #else // freopen("street.in", "r", stdin); // freopen("out.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); } ii solve(int x) { int n = 5e3; for (int a = -n; a <= n; a++) { for (int b = -n; b <= n; b++) { ll A = a * a * a * a * a; ll B = b * b * b * b * b; if (A - B == x) return {a, b}; } } assert(0); return {INT_MIN, INT_MIN}; } int main() { // file(); fast(); int x; cin >> x; cout << solve(x).first << ' ' << solve(x).second << endl; return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <unordered_map> // #include"testlib.h" #define endl "\n" #define all(v) v.begin(), v.end() #define allr(s) s.rbegin(), s.rend() #define RT(s) return cout << s, 0 #define watch(x) cout << (#x) << " = " << x << endl #define sz(s) (int)(s.size()) #define PI acos(-1) #define EPS 1e-100 using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; void file() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); #else // freopen("street.in", "r", stdin); // freopen("out.txt", "w", stdout); #endif } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); } ii solve(int x) { int n = 5e3; for (ll a = -n; a <= n; a++) { for (ll b = -n; b <= n; b++) { ll A = a * a * a * a * a; ll B = b * b * b * b * b; if (A - B == x) return {a, b}; } } assert(0); return {INT_MIN, INT_MIN}; } int main() { // file(); fast(); int x; cin >> x; cout << solve(x).first << ' ' << solve(x).second << endl; return 0; }
replace
36
38
36
38
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 1; i < (ll)(n); i++) #define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++) int main() { ll x; cin >> x; queue<ll> memo; ll karioki = sqrt(x); rep(i, karioki + 1) { if (x % i == 0) { memo.push(i); } } bool flag = false; while (memo.size() > 0) { ll a = memo.front(); memo.pop(); ll m1 = x / a; rep(i, m1 + 1) { if (x == i * i * i * i * i - (i - a) * (i - a) * (i - a) * (i - a) * (i - a)) { cout << i << " " << i - a << endl; break; flag = false; } if (flag) { break; } } } }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 1; i < (ll)(n); i++) #define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++) int main() { ll x; cin >> x; queue<ll> memo; ll karioki = sqrt(x); rep(i, karioki + 1) { if (x % i == 0) { memo.push(i); } } bool flag = false; while (memo.size() > 0) { ll a = memo.front(); memo.pop(); ll m1 = x / a; ll m2 = sqrt(m1); rep(i, m2 + 1) { if (x == i * i * i * i * i - (i - a) * (i - a) * (i - a) * (i - a) * (i - a)) { cout << i << " " << i - a << endl; break; flag = false; } if (flag) { break; } } } }
replace
24
25
24
26
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; int main() { ll x; cin >> x; for (ll a = -64; a <= 64; a++) { ll temp = sqrtl(abs((powl(a, 5) - x))); // cout << temp << endl; for (ll b = temp * -1; b <= temp; b++) { if (powl(a, 5) - powl(b, 5) == x) { cout << a << " " << b; return 0; } } } }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; int main() { ll x; cin >> x; for (ll a = -300; a <= 300; a++) { ll temp = sqrtl(sqrtl(abs((powl(a, 5) - x)))); // cout << temp << endl; for (ll b = temp * -1; b <= temp; b++) { if (powl(a, 5) - powl(b, 5) == x) { cout << a << " " << b; return 0; } } } }
replace
15
17
15
17
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pi; #define f first #define s second #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(0); const int maxn = 100010; int pow5(int x) { return x * x * x * x * x; } int X; int32_t main() { FAST cin >> X; for (int a = 0; a <= 100; a++) { for (int b = -100; b <= 100; b++) { if (pow5(a) - pow5(b) == X) { cout << a << " " << b; return 0; } } } assert(0); }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pi; #define f first #define s second #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(0); const int maxn = 100010; int pow5(int x) { return x * x * x * x * x; } int X; int32_t main() { FAST cin >> X; for (int a = -150; a <= 150; a++) { for (int b = -150; b <= 150; b++) { if (pow5(a) - pow5(b) == X) { cout << a << " " << b; return 0; } } } assert(0); }
replace
16
18
16
18
0
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)n; i++) using namespace std; int main() { ll X; cin >> X; for (ll B = -100000; B <= 1000; B++) { for (ll A = -100; A <= 100; A++) { if (pow(A, 5) == X + pow(B, 5)) { cout << A << " " << B << endl; return 0; } } } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)n; i++) using namespace std; int main() { ll X; cin >> X; for (ll B = -200; B <= 200; B++) { for (ll A = -200; A <= 200; A++) { if (pow(A, 5) == X + pow(B, 5)) { cout << A << " " << B << endl; return 0; } } } return 0; }
replace
17
19
17
19
TLE
p02690
C++
Runtime Error
#include <algorithm> #include <functional> #include <iostream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, n) for (int i = 1; i < 40001; i += 2) using namespace std; using P = pair<int, int>; using ll = long long; int main() { ll x; cin >> x; vector<pair<ll, ll>> A(40001); A[0].first = A[0].second = 0; ll num = 1; rep2(i, 40000) { A[i].first = num * num * num * num * num; A[i].second = num; A[i + 1].first = -num * num * num * num * num; A[i + 1].second = -num; num += 1; } int a, b = 1, anum = 0, bnum = 0, judge = 0; rep(i, 40001) { a = A[i].first; rep(j, 40001) { b = A[j].first; if (a == (x + b)) { judge = 1; anum = A[i].second; bnum = A[j].second; break; } } if (judge == 1) break; } rep(i, 4) { if ((a == 0) && (b == 0)) break; else if (a == 0) b /= bnum; else if (b == 0) a /= anum; else { a /= anum; b /= bnum; } } cout << a << " " << b << endl; }
#include <algorithm> #include <functional> #include <iostream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, n) for (int i = 1; i < 40001; i += 2) using namespace std; using P = pair<int, int>; using ll = long long; int main() { ll x; cin >> x; vector<pair<ll, ll>> A(40001); A[0].first = A[0].second = 0; ll num = 1; rep2(i, 40000) { A[i].first = num * num * num * num * num; A[i].second = num; A[i + 1].first = -num * num * num * num * num; A[i + 1].second = -num; num += 1; } ll a, b = 1, anum = 0, bnum = 0, judge = 0; rep(i, 40001) { a = A[i].first; rep(j, 40001) { b = A[j].first; if (a == (x + b)) { judge = 1; anum = A[i].second; bnum = A[j].second; break; } } if (judge == 1) break; } rep(i, 4) { if ((a == 0) && (b == 0)) break; else if (a == 0) b /= bnum; else if (b == 0) a /= anum; else { a /= anum; b /= bnum; } } cout << a << " " << b << endl; }
replace
25
26
25
26
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define vvi vector<vector<int>> #define all(a) (a).begin(), (a).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) const int MOD = 1e9 + 7; const ll LINF = 1e18; const int INF = 1e9; ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S, T; int main() { cin >> X; for (ll i = 1; i < 100000; i++) { if (X % i == 0) { Y = X / i; // cout << Y << endl; for (ll j = 0; j <= Y; j++) { A = j; B = j - i; ll A2 = A * A; ll B2 = B * B; D = A * B; E = (A * A) + (A * B) + (A * A); if (Y == A2 * A2 + B2 * B2 + D * (A2 + D + B2)) { cout << A << " " << B; return 0; } } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define vvi vector<vector<int>> #define all(a) (a).begin(), (a).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) const int MOD = 1e9 + 7; const ll LINF = 1e18; const int INF = 1e9; ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S, T; int main() { cin >> X; for (ll i = 1; i < 100000; i++) { if (X % i == 0) { Y = X / i; // cout << Y << endl; for (ll j = 0; j <= Y / 2; j++) { A = j; B = j - i; ll A2 = A * A; ll B2 = B * B; D = A * B; E = (A * A) + (A * B) + (A * A); if (Y == A2 * A2 + B2 * B2 + D * (A2 + D + B2)) { cout << A << " " << B; return 0; } } } } return 0; }
replace
21
22
21
22
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define int long long #define INT int #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define all(i) (i).begin(), (i).end() #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } typedef long long ll; /* nの約数を求める関数*/ vector<int> enum_div(int n) // nの約数を列挙 { vector<int> divisor; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { divisor.push_back(i); if (i != 1 && i * i != n) { divisor.push_back(n / i); } } } return divisor; } int x; bool fun(int A, int B) { return A * A * A * A * A - B * B * B * B * B == x; } int fun2(int B, int P) { int temp = ((B + P) * (B + P) + B * B) - (B + P + B) * (B + P + P); int temp2 = (B + P) * B * ((B + P) * (B + P) + (B + P) * B + B * B); return temp - temp2; } signed main() { cin >> x; vector<int> y = enum_div(x); int a, b; for (auto p : y) { rep(i, x) { int _x = i; int _y = _x - p; if (fun(_x, _y)) { cout << _x << " " << _y << endl; break; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define INT int #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define all(i) (i).begin(), (i).end() #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } typedef long long ll; /* nの約数を求める関数*/ vector<int> enum_div(int n) // nの約数を列挙 { vector<int> divisor; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { divisor.push_back(i); if (i != 1 && i * i != n) { divisor.push_back(n / i); } } } return divisor; } int x; bool fun(int A, int B) { return A * A * A * A * A - B * B * B * B * B == x; } int fun2(int B, int P) { int temp = ((B + P) * (B + P) + B * B) - (B + P + B) * (B + P + P); int temp2 = (B + P) * B * ((B + P) * (B + P) + (B + P) * B + B * B); return temp - temp2; } signed main() { cin >> x; vector<int> y = enum_div(x); int a, b; for (auto p : y) { rep(i, 1e6) { int _x = i; int _y = _x - p; if (fun(_x, _y)) { cout << _x << " " << _y << endl; break; } } } return 0; }
replace
54
55
54
55
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { long long X; cin >> X; for (int a = -5000; a <= 5000; a++) { for (int b = -5000; b <= 5000; b++) { long long A = pow(a, 5); long long B = pow(b, 5); if (A - B == X) { cout << a << " " << b << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { long long X; cin >> X; for (int a = -1000; a <= 1000; a++) { for (int b = -1000; b <= 1000; b++) { long long A = pow(a, 5); long long B = pow(b, 5); if (A - B == X) { cout << a << " " << b << endl; return 0; } } } return 0; }
replace
8
10
8
10
TLE
p02690
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string.h> #include <utility> #include <vector> #define s(n) scanf("%d", &n) #define sc(n) scanf("%c", &n) #define sl(n) scanf("%I64d", &n) #define sf(n) scanf("%lf", &n) #define ss(n) scanf("%s", n) #define INF (int)1e9 #define EPS 1e-9 #define bitcount __builtin_popcount #define gcd __gcd #define forall(i, a, b) for (int i = a; i < b; i++) #define foreach(v, c) \ for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v) #define all(a) a.begin(), a.end() #define in(a, b) ((b).find(a) != (b).end()) #define pb push_back #define fill(a, v) memset(a, v, sizeof a) #define sz(a) ((int)(a.size())) #define mp make_pair #define MOD 1000000007 typedef long long ll; /*For you see , each day i love you more.Today more than yesterday less than tomorrow.*/ using namespace std; int main() { vector<ll> powers; for (int i = 0; i <= 119; i++) { ll val = pow(i * 1ll, 5ll); } ll x; cin >> x; // first check for the sum for (int i = 0; i <= 119; i++) { for (int j = i; j >= 0; j--) { if (powers[i] + powers[j] == x) { cout << i << " " << -1 * j << endl; return 0; } if (powers[i] - powers[j] == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string.h> #include <utility> #include <vector> #define s(n) scanf("%d", &n) #define sc(n) scanf("%c", &n) #define sl(n) scanf("%I64d", &n) #define sf(n) scanf("%lf", &n) #define ss(n) scanf("%s", n) #define INF (int)1e9 #define EPS 1e-9 #define bitcount __builtin_popcount #define gcd __gcd #define forall(i, a, b) for (int i = a; i < b; i++) #define foreach(v, c) \ for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v) #define all(a) a.begin(), a.end() #define in(a, b) ((b).find(a) != (b).end()) #define pb push_back #define fill(a, v) memset(a, v, sizeof a) #define sz(a) ((int)(a.size())) #define mp make_pair #define MOD 1000000007 typedef long long ll; /*For you see , each day i love you more.Today more than yesterday less than tomorrow.*/ using namespace std; int main() { vector<ll> powers; for (int i = 0; i <= 119; i++) { ll val = pow(i * 1ll, 5ll); powers.push_back(val); } ll x; cin >> x; // first check for the sum for (int i = 0; i <= 119; i++) { for (int j = i; j >= 0; j--) { if (powers[i] + powers[j] == x) { cout << i << " " << -1 * j << endl; return 0; } if (powers[i] - powers[j] == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
insert
49
49
49
50
-11
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long x; int main() { scanf("%lld", &x); long long ansA = 1e18; long long ansB = -1; for (long long i = -100; i <= 100; i++) { for (long long j = -100; j <= 100; j++) { if (i * i * i * i * i - j * j * j * j * j == x) { ansA = i; ansB = j; break; } } if (ansA != 1e18) break; } assert(ansA != 1e18); printf("%lld %lld\n", ansA, ansB); }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long x; int main() { scanf("%lld", &x); long long ansA = 1e18; long long ansB = -1; for (long long i = -1000; i <= 1000; i++) { for (long long j = -1000; j <= 1000; j++) { if (i * i * i * i * i - j * j * j * j * j == x) { ansA = i; ansB = j; break; } } if (ansA != 1e18) break; } assert(ansA != 1e18); printf("%lld %lld\n", ansA, ansB); }
replace
12
14
12
14
0
p02690
C++
Time Limit Exceeded
#include <iostream> inline long long GetMulti(int val) { return (long long)val * val * val * val * val; } int main() { unsigned int X; std::cin >> X; for (int A = 0;; ++A) { const long long mulA = GetMulti(A); const long long result = mulA - X; if (result < 0) { long long mulB = 0; for (int B = 0; mulB >= result; --B) { mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } else { long long mulB = 0; for (int B = 0; mulB <= result; ++B) { long long mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } } return 0; }
#include <iostream> inline long long GetMulti(int val) { return (long long)val * val * val * val * val; } int main() { unsigned int X; std::cin >> X; for (int A = -200;; ++A) { const long long mulA = GetMulti(A); const long long result = mulA - X; if (result < 0) { long long mulB = 0; for (int B = 0; mulB >= result; --B) { mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } else { long long mulB = 0; for (int B = 0; mulB <= result; ++B) { long long mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } } return 0; }
replace
10
11
10
11
TLE
p02690
C++
Time Limit Exceeded
#include <iostream> inline long long GetMulti(int val) { return (long long)val * val * val * val * val; } int main() { unsigned int X; std::cin >> X; for (int A = 0;; ++A) { const long long mulA = GetMulti(A); const long long result = mulA - X; if (result < 0) { long long mulB = 0; for (int B = 0; mulB >= result; --B) { mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } else { long long mulB = 0; for (int B = 0; mulB <= result; ++B) { long long mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } } return 0; }
#include <iostream> inline long long GetMulti(int val) { return (long long)val * val * val * val * val; } int main() { unsigned int X; std::cin >> X; for (int A = 0;; ++A) { const long long mulA = GetMulti(A); const long long result = mulA - X; if (result < 0) { long long mulB = 0; for (int B = 0; mulB >= result; --B) { mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } else { long long mulB = 0; for (int B = 0; mulB <= result; ++B) { mulB = GetMulti(B); if (result == mulB) { std::cout << A << " " << B << std::endl; return 0; } } } } return 0; }
replace
26
27
26
27
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 vector<int> vt; set<int> st; map<int, int> mp; unordered_map<string, int> umap; const long long MAX = 1e5; const long long INF = 1e9; const double pi = acos(-1); int main() { int x; cin >> x; for (int i = -2000; i <= 2000; i++) for (int j = -2000; j <= 2000; j++) { if ((int)pow(i, 5) == (int)pow(j, 5) + x) { cout << i << " " << j << endl; exit(0); } } }
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 vector<int> vt; set<int> st; map<int, int> mp; unordered_map<string, int> umap; const long long MAX = 1e5; const long long INF = 1e9; const double pi = acos(-1); int main() { int x; cin >> x; for (long long int i = -2000; i <= 2000; i++) for (long long int j = -2000; j <= 2000; j++) { if (i * i * i * i * i == j * j * j * j * j + x) { cout << i << " " << j << endl; exit(0); } } }
replace
15
18
15
18
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> typedef long long ll; const ll MOD = 1e9 + 7; #define REP(i, N) for (ll i = 0; i < (N); i++) #define REPP(i, a, b) for (ll i = (a); i < (b); i++) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define VSORT(c) sort((c).begin(), (c).end()) #define SZ(x) ((ll)(x).size()) // vvintを作る マクロで  #define vvint(N,M) vector<vector<ll>> using namespace std; // 変数初期化 vector<ll> bsv; // binary_search用のvector ll a, b, c, n, m; typedef pair<ll, ll> Pll; vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数) vector<vector<ll>> bit_search_v; // nit全探索の結果格納用 // index が条件を満たすかどうか bool isOK(ll index, ll key) { if (bsv[index] >= key) return true; else return false; } // 汎用的な二分探索のテンプレ ll binary_search(int key) { int ng = -1; int ok = (ll)bsv.size(); /* ok と ng のどちらが大きいかわからないことを考慮 */ while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key)) ok = mid; else ng = mid; } // OK(key以上となる)のindex番号を返す return ok; } // 最大公約数 int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } // 最小公倍数 int lcm(int a, int b) { return a * b / gcd(a, b); } //  素因数分解 void prime_fact(ll target) { ll base = 2, exp = 0; while (base * base <= target) { while (target % base == 0) { target /= base; exp++; } if (exp > 0) { facts.push_back(make_pair(base, exp)); } base++; exp = 0; } if (target > 1) facts.push_back(make_pair(target, 1)); } // prime_factの結果の確認用 void print_facts() { for (int i = 0; i < facts.size(); i++) { cout << facts[i].first << " " << facts[i].second << endl; } } // bit全探索 void bit_search(ll target) { for (ll i = 0; i < (1 << target); ++i) { if (i == 0) continue; vector<ll> v; for (ll j = 0; j < target; ++j) { if (i & (1 << j)) v.push_back(j); if (i & (1 << j)) cout << i << " : " << j << endl; } bit_search_v.push_back(v); } } // bit全探索の結果確認用 void print_bit_search() { for (ll i = 0; i < bit_search_v.size(); ++i) { for (ll j = 0; j < bit_search_v[i].size(); ++j) { cout << bit_search_v[i][j] << " "; } cout << endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll x; cin >> x; a = 0; while (1) { for (ll i = -a; i < a; i++) { for (ll l = -x; l < x; l++) { if (pow(i, 5) - pow(l, 5) == x) { cout << i << " " << l << endl; return 0; } } } a++; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> typedef long long ll; const ll MOD = 1e9 + 7; #define REP(i, N) for (ll i = 0; i < (N); i++) #define REPP(i, a, b) for (ll i = (a); i < (b); i++) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define VSORT(c) sort((c).begin(), (c).end()) #define SZ(x) ((ll)(x).size()) // vvintを作る マクロで  #define vvint(N,M) vector<vector<ll>> using namespace std; // 変数初期化 vector<ll> bsv; // binary_search用のvector ll a, b, c, n, m; typedef pair<ll, ll> Pll; vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数) vector<vector<ll>> bit_search_v; // nit全探索の結果格納用 // index が条件を満たすかどうか bool isOK(ll index, ll key) { if (bsv[index] >= key) return true; else return false; } // 汎用的な二分探索のテンプレ ll binary_search(int key) { int ng = -1; int ok = (ll)bsv.size(); /* ok と ng のどちらが大きいかわからないことを考慮 */ while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(mid, key)) ok = mid; else ng = mid; } // OK(key以上となる)のindex番号を返す return ok; } // 最大公約数 int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } // 最小公倍数 int lcm(int a, int b) { return a * b / gcd(a, b); } //  素因数分解 void prime_fact(ll target) { ll base = 2, exp = 0; while (base * base <= target) { while (target % base == 0) { target /= base; exp++; } if (exp > 0) { facts.push_back(make_pair(base, exp)); } base++; exp = 0; } if (target > 1) facts.push_back(make_pair(target, 1)); } // prime_factの結果の確認用 void print_facts() { for (int i = 0; i < facts.size(); i++) { cout << facts[i].first << " " << facts[i].second << endl; } } // bit全探索 void bit_search(ll target) { for (ll i = 0; i < (1 << target); ++i) { if (i == 0) continue; vector<ll> v; for (ll j = 0; j < target; ++j) { if (i & (1 << j)) v.push_back(j); if (i & (1 << j)) cout << i << " : " << j << endl; } bit_search_v.push_back(v); } } // bit全探索の結果確認用 void print_bit_search() { for (ll i = 0; i < bit_search_v.size(); ++i) { for (ll j = 0; j < bit_search_v[i].size(); ++j) { cout << bit_search_v[i][j] << " "; } cout << endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll x; cin >> x; a = 0; while (1) { for (ll i = -a; i < a; i++) { for (ll l = -120; l < 120; l++) { if (pow(i, 5) - pow(l, 5) == x) { cout << i << " " << l << endl; return 0; } } } a++; } return 0; }
replace
130
131
130
131
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define REPR(i, n) for (ll i = (ll)n - 1; i >= 0; i--) #define FOR(i, m, n) for (ll i = (ll)m; i < (ll)n; i++) #define FORR(i, m, n) for (ll i = (ll)m - 1; i >= (ll)n; i--) #define ALL(x) (x).begin(), (x).end() #define ASC(v) sort(ALL(v)); #define DESC(v) sort(ALL(v), greater<int>()); #define UNIQ(a) \ sort(ALL(a)); \ (a).resize(unique(ALL(a)) - a.begin()); #define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n"; #define DEBUG(x) cout << #x << ": " << x << "\n" const double PI = acos(-1); ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool isprime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } int digsum(int n) { int r = 0; while (n > 0) { r += n % 10; n /= 10; } return r; } 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; } struct nya { nya() { cin.tie(0); ios::sync_with_stdio(false); } } nyan; int main() { ll X; cin >> X; FOR(A, -3e3, 3e3) { FOR(B, -3e3, 3e3) { if (pow(A, 5) - pow(B, 5) == X) { cout << A << " " << B << "\n"; return 0; } } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define REPR(i, n) for (ll i = (ll)n - 1; i >= 0; i--) #define FOR(i, m, n) for (ll i = (ll)m; i < (ll)n; i++) #define FORR(i, m, n) for (ll i = (ll)m - 1; i >= (ll)n; i--) #define ALL(x) (x).begin(), (x).end() #define ASC(v) sort(ALL(v)); #define DESC(v) sort(ALL(v), greater<int>()); #define UNIQ(a) \ sort(ALL(a)); \ (a).resize(unique(ALL(a)) - a.begin()); #define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n"; #define DEBUG(x) cout << #x << ": " << x << "\n" const double PI = acos(-1); ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } bool isprime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } int digsum(int n) { int r = 0; while (n > 0) { r += n % 10; n /= 10; } return r; } 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; } struct nya { nya() { cin.tie(0); ios::sync_with_stdio(false); } } nyan; int main() { ll X; cin >> X; FOR(A, -2e3, 2e3) { FOR(B, -2e3, 2e3) { if (pow(A, 5) - pow(B, 5) == X) { cout << A << " " << B << "\n"; return 0; } } } }
replace
62
64
62
64
TLE
p02690
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; long long five[101]; long long p5(int i) { if (five[i]) return five[i]; else { long long tmp = i * i; tmp *= tmp; tmp *= i; five[i] = tmp; return tmp; } } void Main() { long long X; cin >> X; for (int i = 0; i <= 200; i++) { for (int j = 0; j <= 200; j++) { if (p5(j) - p5(i) == X) { cout << j << " " << i << endl; return; } else if (p5(j) + p5(i) == X) { cout << j << " " << -i << endl; return; } } } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include "bits/stdc++.h" using namespace std; long long five[201]; long long p5(int i) { if (five[i]) return five[i]; else { long long tmp = i * i; tmp *= tmp; tmp *= i; five[i] = tmp; return tmp; } } void Main() { long long X; cin >> X; for (int i = 0; i <= 200; i++) { for (int j = 0; j <= 200; j++) { if (p5(j) - p5(i) == X) { cout << j << " " << i << endl; return; } else if (p5(j) + p5(i) == X) { cout << j << " " << -i << endl; return; } } } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
replace
3
4
3
4
0
p02690
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, s, n) for (int i = (s); i < (n); i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (int i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front const int mod = 1e9 + 7; typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; int main() { ll x; cin >> x; for (ll a = -10000; a <= 10000; a++) { for (ll b = -10000; b <= 10000; b++) { if (pow(a, 5) - pow(b, 5) == x) { cout << a << " " << b << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, s, n) for (int i = (s); i < (n); i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define REPR(i, s, n) for (int i = (s); i >= (n); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front const int mod = 1e9 + 7; typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; int main() { ll x; cin >> x; for (ll a = -1000; a <= 1000; a++) { for (ll b = -1000; b <= 1000; b++) { if (pow(a, 5) - pow(b, 5) == x) { cout << a << " " << b << endl; return 0; } } } return 0; }
replace
17
19
17
19
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; for (int i = 0; i <= 10000; i++) { for (int j = -10000; j <= 0; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; for (int i = 0; i <= 5000; i++) { for (int j = -2500; j <= 2500; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
6
8
6
8
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target( \ "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("-ffloat-store") #define fastio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl "\n" #define sz(a) ((int)(a).size()) #define all(v) (v).begin(), (v).end() #define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++) #define pres(c, val) ((c).find(val) != (c).end()) // #define cpres(c, val) (find(all(c), val) != (c).end()) // #define pb push_back #define mp make_pair #define F first #define S second #define forf(i, a, b) for (int i = (a); i < (b); i++) #define forb(i, a, b) for (int i = (b); i >= (a); i--) #define fo(i, n) forf(i, 0, n) #define fob(i, n) forb(i, 0, n - 1) typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int>> vpii; const int INF = 9e18; // const int N = 1e9 + 7; const int N = 998244353; const auto start_time = std::chrono::high_resolution_clock::now(); void zark() { #ifdef ZARK auto end_time = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = end_time - start_time; cerr << "Time Taken : " << diff.count() << "s\n"; #endif } #ifdef ZARK #include "/home/aranjan/Desktop/CP/header.h" #else #define dbg(args...) #endif /* ------------------ Actual Coding Starts ------------------ */ bool ispow5(int n) { int x = pow(n, 0.2); return x * x * x * x * x == n; } void solve() { int x; cin >> x; fo(i, pow(x, 0.2)) { if (ispow5(x - i * i * i * i * i)) { cout << pow(x - i * i * i * i * i, 0.2) << " " << -i << endl; return; } } int i = 0; while (1) { if (ispow5(x + i * i * i * i * i)) { cout << pow(x + i * i * i * i * i, 0.2) << " " << i << endl; return; } } } int32_t main() { fastio; #ifdef ZARK freopen("input.in", "r", stdin); #endif // freopen("txt.in", "r", stdin); // freopen("txt.out", "w", stdout); // cout << fixed << setprecision(35); solve(); zark(); return 0; }
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target( \ "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("-ffloat-store") #define fastio \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl "\n" #define sz(a) ((int)(a).size()) #define all(v) (v).begin(), (v).end() #define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++) #define pres(c, val) ((c).find(val) != (c).end()) // #define cpres(c, val) (find(all(c), val) != (c).end()) // #define pb push_back #define mp make_pair #define F first #define S second #define forf(i, a, b) for (int i = (a); i < (b); i++) #define forb(i, a, b) for (int i = (b); i >= (a); i--) #define fo(i, n) forf(i, 0, n) #define fob(i, n) forb(i, 0, n - 1) typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int>> vpii; const int INF = 9e18; // const int N = 1e9 + 7; const int N = 998244353; const auto start_time = std::chrono::high_resolution_clock::now(); void zark() { #ifdef ZARK auto end_time = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = end_time - start_time; cerr << "Time Taken : " << diff.count() << "s\n"; #endif } #ifdef ZARK #include "/home/aranjan/Desktop/CP/header.h" #else #define dbg(args...) #endif /* ------------------ Actual Coding Starts ------------------ */ bool ispow5(int n) { int x = pow(n, 0.2); return x * x * x * x * x == n; } void solve() { int x; cin >> x; fo(i, pow(x, 0.2)) { if (ispow5(x - i * i * i * i * i)) { cout << pow(x - i * i * i * i * i, 0.2) << " " << -i << endl; return; } } for (int d = 1; d * d <= x; d++) { int k = x / d; for (int b = 0; pow((b + d), 4) + pow((b + d), 3) * b + (b + d) * (b + d) * b * b + (b + d) * b * b * b + b * b * b * b <= k; b++) { if (pow((b + d), 4) + pow((b + d), 3) * b + (b + d) * (b + d) * b * b + (b + d) * b * b * b + b * b * b * b == k) { cout << b + d << " " << b << endl; return; } } for (int b = 0; pow((b + k), 4) + pow((b + k), 3) * b + (b + k) * (b + k) * b * b + (b + k) * b * b * b + b * b * b * b <= d; b++) { if (pow((b + k), 4) + pow((b + k), 3) * b + (b + k) * (b + k) * b * b + (b + k) * b * b * b + b * b * b * b == k) { cout << b + k << " " << b << endl; return; } } } } int32_t main() { fastio; #ifdef ZARK freopen("input.in", "r", stdin); #endif // freopen("txt.in", "r", stdin); // freopen("txt.out", "w", stdout); // cout << fixed << setprecision(35); solve(); zark(); return 0; }
replace
73
78
73
98
TLE
p02690
C++
Runtime Error
#include <stdio.h> int main() { int X; while (scanf("%d", &X) != 0) { for (long long A = 0; A < 120; A++) for (long long B = -120; B < A; B++) if (A * A * A * A * A - B * B * B * B * B == X) return printf("%lld %lld\n", A, B); } }
#include <stdio.h> int main() { int X; while (scanf("%d", &X) != 0) { for (long long A = 0; A < 120; A++) for (long long B = -120; B < A; B++) if (A * A * A * A * A - B * B * B * B * B == X) return printf("%lld %lld\n", A, B), 0; } }
replace
7
8
7
8
5
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; 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 INF = 1LL << 60; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int64_t x; cin >> x; int64_t a = 0, b = 1; int64_t insuu; for (int i = 2; i * i <= x; i++) { if (x % i == 0) { insuu = i; break; } } for (int64_t i = (-1000) * insuu;; i += insuu) { double ggg = pow(i, 5); double gggg = ggg + x; double g = pow(gggg, 0.2); int64_t gg = pow(gggg, 0.2); if (floor(g) == g) { a = gg; b = i; break; } } cout << a << " " << b << endl; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; 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 INF = 1LL << 60; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int64_t x; cin >> x; int64_t a = 0, b = 0; for (int i = -500; i <= 500; i++) { for (int j = -500; j <= 500; j++) { if (pow(i, 5) - pow(j, 5) == x) { a = i; b = j; break; } } } cout << a << " " << b << endl; }
replace
28
45
28
36
TLE
p02690
C++
Time Limit Exceeded
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, x, y) for (int i = x; i < y; i++) #define gcd(a, b) __gcd(a, b) #define lcm(a, b) a / __gcd(a, b) * b #define range(a) (a).begin(), (a).end() const int inf = 2147483647; int main() { int X; cin >> X; ll ansa, ansb; rep(i, -4000, 4000) { rep(j, -4000, 4000) { if (X == pow(j, 5.0) - pow(i, 5.0)) { ansa = j; ansb = i; break; } } } cout << ansa << " " << ansb << endl; }
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, x, y) for (int i = x; i < y; i++) #define gcd(a, b) __gcd(a, b) #define lcm(a, b) a / __gcd(a, b) * b #define range(a) (a).begin(), (a).end() const int inf = 2147483647; int main() { int X; cin >> X; ll ansa, ansb; rep(i, -400, 400) { rep(j, -400, 400) { if (X == pow(j, 5.0) - pow(i, 5.0)) { ansa = j; ansb = i; break; } } } cout << ansa << " " << ansb << endl; }
replace
15
17
15
17
TLE
p02690
C++
Time Limit Exceeded
// // main.cpp // CoderProj // // Created by Minoru Hayashi on 2020/05/02. // Copyright © 2020 Minoru Hayashi. All rights reserved. // // ABC165 // // #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) using ll = long long; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } // const ll INF = 1LL<<60; // const int INF = 1<<29; // const int MOD = 1000000007; // #define __DBG__ void solve(void) { ll X; cin >> X; ll Aans = 0; ll Bans = 0; REP2(A, -100, 1000000) { REP2(B, -100, 10000) { if (A * A * A * A * A - B * B * B * B * B == X) { Aans = A; Bans = B; break; } } } cout << Aans << " " << Bans << endl; return; } #define TESTCASES 1 int main() { cin.tie(0); ios::sync_with_stdio(false); REP(i, TESTCASES) { solve(); } return 0; }
// // main.cpp // CoderProj // // Created by Minoru Hayashi on 2020/05/02. // Copyright © 2020 Minoru Hayashi. All rights reserved. // // ABC165 // // #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) using ll = long long; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } // const ll INF = 1LL<<60; // const int INF = 1<<29; // const int MOD = 1000000007; // #define __DBG__ void solve(void) { ll X; cin >> X; ll Aans = 0; ll Bans = 0; REP2(A, -120, 120) { REP2(B, -120, 120) { if (A * A * A * A * A - B * B * B * B * B == X) { Aans = A; Bans = B; break; } } } cout << Aans << " " << Bans << endl; return; } #define TESTCASES 1 int main() { cin.tie(0); ios::sync_with_stdio(false); REP(i, TESTCASES) { solve(); } return 0; }
replace
49
51
49
51
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define SP << " " using namespace std; void PV(vector<int> pvv) { rep(i, pvv.size()) cout << pvv[i] SP; cout << endl; } int main() { long long int x, t = 0; vector<int> v; cin >> x; while (t * t * t * t * t / t / t / t / t / t == 1) { v.push_back(t * t * t * t * t); // cout << t * t*t*t*t << endl; auto itr = lower_bound(v.begin(), v.end(), x - t * t * t * t * t); if (*itr == x - t * t * t * t * t) { cout << t SP << -1 * (itr - v.begin()) << endl; return 0; } auto itr2 = lower_bound(v.begin(), v.end(), t * t * t * t * t - x); if (*itr2 == t * t * t * t * t - x) { cout << t SP << itr2 - v.begin() << endl; return 0; } t++; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define SP << " " using namespace std; void PV(vector<int> pvv) { rep(i, pvv.size()) cout << pvv[i] SP; cout << endl; } int main() { long long int x, t = 0; vector<long long int> v; cin >> x; while (t * t * t * t * t / t / t / t / t / t == 1) { v.push_back(t * t * t * t * t); // cout << t * t*t*t*t << endl; auto itr = lower_bound(v.begin(), v.end(), x - t * t * t * t * t); if (*itr == x - t * t * t * t * t) { cout << t SP << -1 * (itr - v.begin()) << endl; return 0; } auto itr2 = lower_bound(v.begin(), v.end(), t * t * t * t * t - x); if (*itr2 == t * t * t * t * t - x) { cout << t SP << itr2 - v.begin() << endl; return 0; } t++; } return 0; }
replace
15
16
15
16
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; using vpii = vector<pair<int, int>>; using vpll = vector<pair<ll, ll>>; // ceil() 切り上げ, floor() 切り捨て // next_permutation(all(x)) int main(void) { ll X; cin >> X; ll A = 0; ll B = -10000; while (pow(A, 5LL) < X) A++; while (B < 10000 && pow(A, 5LL) - pow(B, 5LL) != X) B++; if (B != 10000) cout << A << " " << B << endl; else { A--; B = -10000; while (pow(A, 5LL) - pow(B, 5LL) != X) B++; cout << A << " " << B << endl; } }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; using vpii = vector<pair<int, int>>; using vpll = vector<pair<ll, ll>>; // ceil() 切り上げ, floor() 切り捨て // next_permutation(all(x)) int main(void) { ll X; cin >> X; for (ll A = -1000LL; A < 1000LL; A++) { for (ll B = -1000LL; B < 1000LL; B++) { if (pow(A, 5LL) - pow(B, 5LL) == X) { cout << A << " " << B << endl; return (0); } } } }
replace
15
29
15
22
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define __ << ' ' << #define ___ << ' ' #define bash push_back #define ALL(x) x.begin(), x.end() // #define int long long struct IoSetup { IoSetup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); cerr << fixed << setprecision(12); } } IoSetup; using ll = long long; using pii = pair<int, int>; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int SMOD = 1000000007; constexpr int NMOD = 998244353; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; inline bool inside(int x, int y, int w, int h) { return (x >= 0 && y >= 0 && x < w && y < h); } template <class T> bool chmax(T &a, const T &b) { return (a < b ? a = b, true : false); } template <class T> bool chmin(T &a, const T &b) { return (a > b ? a = b, true : false); } inline int qp(int a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } signed main() { ll x; cin >> x; ll s = 0, i = 0; vector<pair<ll, int>> v; while (abs(s) < 1e9) { s = i * i * i * i * i; v.bash({s, i}); v.bash({-s, -i}); ++i; } sort(ALL(v)); for (auto &&a : v) { auto p = *lower_bound(ALL(v), pair<ll, int>(a.first - x, -INF)); if (a.first - p.first == x) { cout << a.second __ p.second << endl; return 0; } } return 1; return 0; }
#include <bits/stdc++.h> using namespace std; #define __ << ' ' << #define ___ << ' ' #define bash push_back #define ALL(x) x.begin(), x.end() // #define int long long struct IoSetup { IoSetup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); cerr << fixed << setprecision(12); } } IoSetup; using ll = long long; using pii = pair<int, int>; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int SMOD = 1000000007; constexpr int NMOD = 998244353; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; inline bool inside(int x, int y, int w, int h) { return (x >= 0 && y >= 0 && x < w && y < h); } template <class T> bool chmax(T &a, const T &b) { return (a < b ? a = b, true : false); } template <class T> bool chmin(T &a, const T &b) { return (a > b ? a = b, true : false); } inline int qp(int a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } signed main() { ll x; cin >> x; ll s = 0, i = 0; vector<pair<ll, int>> v; while (abs(s) < 1e18) { s = i * i * i * i * i; v.bash({s, i}); v.bash({-s, -i}); ++i; } sort(ALL(v)); for (auto &&a : v) { auto p = *lower_bound(ALL(v), pair<ll, int>(a.first - x, -INF)); if (a.first - p.first == x) { cout << a.second __ p.second << endl; return 0; } } return 1; return 0; }
replace
53
54
53
54
0
p02690
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using llong = long long; llong f(llong x) { return x * x * x * x * x; } int main() { llong x; cin >> x; for (llong i = -64; i <= 64; i++) { for (llong j = -64; j <= 64; j++) { if (f(i) - f(j) == x) { cout << i << ' ' << j << endl; return 0; } } } return 1; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using llong = long long; llong f(llong x) { return x * x * x * x * x; } int main() { llong x; cin >> x; for (int i = -1000; i <= 1000; i++) { llong y = x + f(i); for (int j = 0; j <= 1024; j++) { if (f(j) == y) { cout << j << ' ' << i << endl; return 0; } } } return 1; }
replace
22
26
22
28
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N / i != i) res.push_back(N / i); } } // 小さい順に並び替える sort(res.begin(), res.end()); return res; } int main() { int N; cin >> N; const auto &res = enum_divisors(N); for (int i = 0; i < res.size(); ++i) { rep(a, N) { if (pow(a, 5) - pow(a - res[i], 5) == N) { cout << a << ' ' << a - res[i] << endl; return 0; } if (pow(a, 5) - pow(res[i] - a, 5) == N) { cout << a << ' ' << res[i] - a << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N / i != i) res.push_back(N / i); } } // 小さい順に並び替える sort(res.begin(), res.end()); return res; } int main() { int N; cin >> N; const auto &res = enum_divisors(N); for (int i = 0; i < res.size(); ++i) { for (int a = 0; a < sqrt(N); ++a) { if (pow(a, 5) - pow(a - res[i], 5) == N) { cout << a << ' ' << a - res[i] << endl; return 0; } if (pow(a, 5) - pow(res[i] - a, 5) == N) { cout << a << ' ' << res[i] - a << endl; return 0; } } } return 0; }
replace
25
26
25
26
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll X; cin >> X; for (int i = -10000; i <= 10000; i++) { for (int j = -10000; j <= 10000; j++) { if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll X; cin >> X; for (int i = -1000; i <= 1000; i++) { for (int j = -1000; j <= 1000; j++) { if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j << endl; return 0; } } } }
replace
9
11
9
11
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repc(i, a, b) for (int i = a; i <= (int)(b); i++) #define ll long long #define vec vector #define ft first #define sd second #define all(vec) vec.begin(), vec.end() typedef pair<int, int> P; const int MOD = 1e9 + 7; const int INF = 1001001001; int main() { ll x; cin >> x; for (ll a = -2000; a <= 2000; a++) for (ll b = -2000; b <= 2000; b++) { if (x % (a + b) == 0) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repc(i, a, b) for (int i = a; i <= (int)(b); i++) #define ll long long #define vec vector #define ft first #define sd second #define all(vec) vec.begin(), vec.end() typedef pair<int, int> P; const int MOD = 1e9 + 7; const int INF = 1001001001; int main() { ll x; cin >> x; for (ll a = -200; a <= 200; a++) for (ll b = -200; b <= 200; b++) { if ((a - b) != 0 && x % (a - b) == 0) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } return 0; }
replace
17
20
17
20
-8
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { map<int, pair<int, int>> check; for (int i = -10000; i < 10000; i++) { for (int j = -10000; j < 10000; j++) { check[pow(i, 5) - pow(j, 5)] = make_pair(i, j); } } int x; cin >> x; cout << check[x].first << ' ' << check[x].second; }
#include <bits/stdc++.h> using namespace std; int main() { map<int, pair<int, int>> check; for (int i = -1000; i <= 1000; i++) { for (int j = -1000; j <= 1000; j++) { check[pow(i, 5) - pow(j, 5)] = make_pair(i, j); } } int x; cin >> x; cout << check[x].first << ' ' << check[x].second; }
replace
4
6
4
6
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int x, t, c; cin >> x; t = x; c = 0; c = 10000; for (int i = c; i >= -c; i--) { for (int j = c; j >= -c; j--) { int u = pow(i, 5) - pow(j, 5); if (u == x) { cout << i << " " << j; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, t, c; cin >> x; t = x; c = 0; c = 1000; for (int i = c; i >= -c; i--) { for (int j = c; j >= -c; j--) { int u = pow(i, 5) - pow(j, 5); if (u == x) { cout << i << " " << j; return 0; } } } return 0; }
replace
7
8
7
8
TLE
p02690
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { // your code goes here int x; cin >> x; for (long long i = 0; i <= 10000; i++) { for (long long j = -100000; j <= 100000; j++) { if ((pow(i, 5) - pow(j, 5)) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { // your code goes here int x; cin >> x; int flag = 0; for (long long i = 0; i < 10000; i++) { for (long long j = -10000; j < 10000; j++) { if ((pow(i, 5) - pow(j, 5)) == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
8
10
8
11
TLE
p02690
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, l, r) for (int i = (l); i < (r); i++) #define ALL(x) (x).begin(), (x).end() // 昇順 #define RALL(x) (x).rbegin(), (x).rend() // 降順 const long long mod = 1e9 + 7; typedef long long ll; typedef priority_queue<int> PQ; typedef vector<long long> VL; typedef vector<bool> VB; typedef vector<int> VI; // VI a(n); typedef vector<double> VD; typedef vector<string> VS; typedef vector<char> VC; typedef vector<VS> VSS; typedef vector<VC> VCC; typedef vector<VI> VII; // VII a(n,vector<int>(m)) n * m typedef vector<VL> VLL; typedef pair<int, int> PII; typedef map<int, int> MP; // MP a; typedef vector<pair<ll, ll>> PS; template <class T, class U> bool chmax(T &a, U b) { if (a <= b) { a = b; return 1; } return 0; } template <class T, class U> bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; } // g++ -std=c++11 prac.cpp // operator << (cout,a); // chmin(min,a) vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { ll x = 0, y = 0, z = 0, n, m, ans = 0, sum = 0, k, w, Max = -1, Min = 1e9 + 1; bool ok = true; string s, t; cin >> x; VL a = divisor(x); for (int i = 0; i <= x; i++) { rep(j, a.size()) { y = i - a[j]; sum = pow(i, 4) + pow(i, 3) * y + pow(i, 2) * pow(y, 2) * pow(y, 3) * i + pow(y, 3); if ((i - y) * sum == x) cout << i << " " << -1 * y << endl; } } return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, l, r) for (int i = (l); i < (r); i++) #define ALL(x) (x).begin(), (x).end() // 昇順 #define RALL(x) (x).rbegin(), (x).rend() // 降順 const long long mod = 1e9 + 7; typedef long long ll; typedef priority_queue<int> PQ; typedef vector<long long> VL; typedef vector<bool> VB; typedef vector<int> VI; // VI a(n); typedef vector<double> VD; typedef vector<string> VS; typedef vector<char> VC; typedef vector<VS> VSS; typedef vector<VC> VCC; typedef vector<VI> VII; // VII a(n,vector<int>(m)) n * m typedef vector<VL> VLL; typedef pair<int, int> PII; typedef map<int, int> MP; // MP a; typedef vector<pair<ll, ll>> PS; template <class T, class U> bool chmax(T &a, U b) { if (a <= b) { a = b; return 1; } return 0; } template <class T, class U> bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; } // g++ -std=c++11 prac.cpp // operator << (cout,a); // chmin(min,a) vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { ll x = 0, y = 0, z = 0, n, m, ans = 0, sum = 0, k, w, Max = -1, Min = 1e9 + 1; bool ok = true; string s, t; cin >> x; for (ll i = -200; i <= 200; i++) { for (ll j = -200; j <= 200; j++) { if (i * i * i * i * i - j * j * j * j * j == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
66
74
66
72
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long X, A, B; cin >> X; for (int i = 0; i < 10000000; i++) { for (int j = i - 65; j < i + 1000; j++) { A = i * i * i * i * i; B = j * j * j * j * j; if (A - B == X) { cout << i << " " << j << endl; goto as; } } } as: cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long X, A, B; cin >> X; for (long long i = -200; i < 200; i++) { for (long long j = -200; j < 200; j++) { A = i * i * i * i * i; B = j * j * j * j * j; if (A - B == X) { cout << i << " " << j << endl; goto as; } } } as: cout << endl; }
replace
5
7
5
7
TLE
p02690
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; using ll = long long; int main(void) { ll x; cin >> x; for (ll a = 0; a <= 1000000000; a++) { if (a <= x) { for (ll b = 0; b < a; b++) { if (a * a * a * a * a + b * b * b * b * b == x) { cout << a << " " << -b << endl; return 0; } } } else { for (ll b = 0; b < a; b++) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } } }
#include <iostream> #include <vector> using namespace std; using ll = long long; int main(void) { ll x; cin >> x; for (ll a = -120; a <= 120; a++) { for (ll b = -120; b <= 120; b++) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } }
replace
9
23
9
15
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> #define log(x) cout << x << endl #define pb push_back #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() typedef long long lint; using namespace std; 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 INF = 1LL << 60; // <<fixed<<setprecision(6)<< int gcd(lint x, lint y) { return y == 0 ? x : gcd(y, x % y); } int digsum(int n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } int dignum(int n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } int lcm(lint x, lint y) { return x / gcd(x, y) * y; } int combi(int n, int r) { int num = 1; for (int i = 1; i <= r; i++) { num = num * (n - i + 1) / i; } return num; } int main() { lint x; cin >> x; lint a, b; bool is = true; for (lint i = -1; i < 10000; i++ && is) { for (lint j = -1; j < 10000; j++ && is) { if (pow(i, 5) - pow(j, 5) == x) { a = i; b = j; is = false; break; } } } cout << a << " " << b; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> #define log(x) cout << x << endl #define pb push_back #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() typedef long long lint; using namespace std; 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 INF = 1LL << 60; // <<fixed<<setprecision(6)<< int gcd(lint x, lint y) { return y == 0 ? x : gcd(y, x % y); } int digsum(int n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } int dignum(int n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } int lcm(lint x, lint y) { return x / gcd(x, y) * y; } int combi(int n, int r) { int num = 1; for (int i = 1; i <= r; i++) { num = num * (n - i + 1) / i; } return num; } int main() { lint x; cin >> x; lint a, b; bool is = true; for (lint i = -300; i < 300; i++ && is) { for (lint j = -300; j < 300; j++ && is) { if (pow(i, 5) - pow(j, 5) == x) { a = i; b = j; is = false; break; } } } cout << a << " " << b; }
replace
74
76
74
76
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int #define ul unsigned long long int #define va vector<long long int> a #define vb vector<long long int> b #define M 1000000007 using namespace std; ll t; void fast() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); } ll power(ll x, ul y, ll p) { ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res % p; } void solve() { ll n; cin >> n; for (ll i = -1000; i < 1000; i++) { for (ll j = -1000; j < 1000; j++) { // cout<<(power(i,5,M)-power(i,5,M))%M<<"\n"; if ((i * i * i * i * i) - (j * j * j * j * j) == n) { cout << i << " " << j << "\n"; i = 100; j = 100; } } } } int main() { fast(); solve(); return 0; }
#include <bits/stdc++.h> #define ll long long int #define ul unsigned long long int #define va vector<long long int> a #define vb vector<long long int> b #define M 1000000007 using namespace std; ll t; void fast() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); } ll power(ll x, ul y, ll p) { ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res % p; } void solve() { ll n; cin >> n; for (ll i = -1000; i < 1000; i++) { for (ll j = -1000; j < 1000; j++) { // cout<<(power(i,5,M)-power(i,5,M))%M<<"\n"; if ((i * i * i * i * i) - (j * j * j * j * j) == n) { cout << i << " " << j << "\n"; i = 1000; j = 1000; } } } } int main() { fast(); solve(); return 0; }
replace
34
36
34
36
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long X; cin >> X; for (int i = -130; i < 130; i++) { for (int j = -130; j < i; j++) { if (i * i * i * i + j * i * i * i + i * i * j * j * +j * j * j * i + j * j * j * j == X / i - j) { cout << i << " " << j << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { long long X; cin >> X; for (int i = -1000; i < 1000; i++) { for (int j = -1000; j < i; j++) { if (i * i * i * i * i - j * j * j * j * j == X) { cout << i << " " << j << endl; return 0; } } } }
replace
6
11
6
9
-8
p02690
C++
Runtime Error
#include <cstdio> typedef long long ll; inline int rd() { int x = 0, p = 1; char a = getchar(); while ((a < 48 || a > 57) && a != '-') a = getchar(); if (a == '-') p = -p, a = getchar(); while (a > 47 && a < 58) x = (x << 1) + (x << 3) + (a & 15), a = getchar(); return x * p; } ll x; int main() { x = rd(); for (ll a = 0; a <= 1000; a++) for (ll b = -1000; b <= 1000; b++) if ((1ll * a * a * a * a * a - 1ll * b * b * b * b * b) == x) return printf("%lld %lld\n", a, b); return 0; }
#include <cstdio> typedef long long ll; inline int rd() { int x = 0, p = 1; char a = getchar(); while ((a < 48 || a > 57) && a != '-') a = getchar(); if (a == '-') p = -p, a = getchar(); while (a > 47 && a < 58) x = (x << 1) + (x << 3) + (a & 15), a = getchar(); return x * p; } ll x; int main() { x = rd(); for (ll a = 0; a <= 1000; a++) for (ll b = -1000; b <= 1000; b++) if ((1ll * a * a * a * a * a - 1ll * b * b * b * b * b) == x) return printf("%lld %lld\n", a, b), 0; return 0; }
replace
19
20
19
20
5
p02690
C++
Time Limit Exceeded
#include <iostream> #include <map> #include <math.h> #include <string> #include <vector> using namespace std; int main() { long long int X; cin >> X; for (long long int i = -100; i <= 100; i++) { for (long long int j = -100; j <= 100; j++) { long long int ans = (int)pow(i, 5) - (int)pow(j, 5); if (ans == X) { cout << i << " " << j << endl; return 0; } } } long long int loop = 2 * (int)pow(10, 4); for (long long int i = 101; i <= loop; i++) { for (long long int j = i; j > 0; j--) { long long int ans = (int)pow(i, 5) - (int)pow(j, 5); if (ans > (long long int)pow(10, 9)) break; if (ans == X) { cout << i << " " << j << endl; return 0; } } } return 0; }
#include <iostream> #include <map> #include <math.h> #include <string> #include <vector> using namespace std; int main() { long long int X; cin >> X; for (long long int i = -200; i <= 200; i++) { for (long long int j = -200; j <= 200; j++) { long long int ans = (long long)pow(i, 5) - (long long)pow(j, 5); if (ans == X) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
10
25
10
13
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() template <typename T> void chmin(T &a, const T &b) { a = min(a, b); } template <typename T> void chmax(T &a, const T &b) { a = max(a, b); } struct FastIO { FastIO() { cin.tie(0); ios::sync_with_stdio(0); } } fastiofastio; #ifdef DEBUG #include "../program_contest_library/memo/dump.hpp" #else #define dump(...) #endif const ll INF = 1LL << 60; int main(void) { ll x; cin >> x; for (ll a = -100; a <= 100; ++a) for (ll b = -100; b <= 100; ++b) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } assert(false); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() template <typename T> void chmin(T &a, const T &b) { a = min(a, b); } template <typename T> void chmax(T &a, const T &b) { a = max(a, b); } struct FastIO { FastIO() { cin.tie(0); ios::sync_with_stdio(0); } } fastiofastio; #ifdef DEBUG #include "../program_contest_library/memo/dump.hpp" #else #define dump(...) #endif const ll INF = 1LL << 60; int main(void) { ll x; cin >> x; for (ll a = -3000; a <= 3000; ++a) for (ll b = -3000; b <= 3000; ++b) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } assert(false); return 0; }
replace
26
28
26
28
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { ll x; cin >> x; for (ll i = -118; i <= 119; i++) { for (ll j = -119; j = 118; j++) { if ((i * i * i * i * i - j * j * j * j * j) == x) { cout << i << endl << j << endl; x = 0; break; } } if (x == 0) break; } }
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { ll x; cin >> x; for (ll i = -118; i <= 119; i++) { for (ll j = -119; j <= 118; j++) { if ((i * i * i * i * i - j * j * j * j * j) == x) { cout << i << endl << j << endl; x = 0; break; } } if (x == 0) break; } }
replace
16
17
16
17
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define eb emplace_back #define mp make_pair #define deb(x) cout << #x << " " << x << "\n"; #define pi 3.1415926535897932384626433832795 #define mod 1000000007 #define all(x) x.begin(), x.end() #define cr7 \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (((a) * (b)) / gcd((a), (b))) // POWER FUNCTION ll power(ll x, ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return ((temp) * (temp)); else return (x * (temp) * (temp)); } int main() { cr7 #ifndef ONLINE_JUDGE freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout); #endif ll x; cin >> x; ll a = 1; while (1) { for (ll b = a - 1; b >= -a; ++b) { if (power(a, 5) - power(b, 5) == x) { cout << a << " " << b << "\n"; return 0; } } a++; } return 0; } // OUTPUT /* */
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define eb emplace_back #define mp make_pair #define deb(x) cout << #x << " " << x << "\n"; #define pi 3.1415926535897932384626433832795 #define mod 1000000007 #define all(x) x.begin(), x.end() #define cr7 \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define gcd(a, b) __gcd(a, b) #define lcm(a, b) (((a) * (b)) / gcd((a), (b))) // POWER FUNCTION ll power(ll x, ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return ((temp) * (temp)); else return (x * (temp) * (temp)); } int main() { cr7 #ifndef ONLINE_JUDGE freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout); #endif ll x; cin >> x; ll a = 1; while (1) { for (ll b = a - 1; b >= -a; --b) { if (power(a, 5) - power(b, 5) == x) { cout << a << " " << b << "\n"; return 0; } } a++; } return 0; } // OUTPUT /* */
replace
38
39
38
39
TLE
p02690
C++
Runtime Error
// https://atcoder.jp/contests/abc166/tasks/abc166_d #include <bits/stdc++.h> #if LOCAL #include "dump.hpp" #else #define dump(...) #endif using namespace std; using ll = long long; const ll LINF = 0x1fffffffffffffff; #define FOR(i, a, b) for (ll i = (a); i < static_cast<ll>(b); ++i) #define REP(i, n) FOR(i, 0, n) 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 (b < a) { a = b; return 1; } return 0; } int main() { ll X; cin >> X; unordered_map<ll, ll> vtbl; vector<ll> nums; { ll i = 0; while (true) { auto i5 = i * i * i * i * i; if (i5 > 1e+9) break; vtbl[i5] = i; vtbl[-i5] = -i; nums.push_back(i5); nums.push_back(-i5); dump(i5); ++i; } } dump(nums.size()) FOR(i, 0, nums.size()) { FOR(j, 0, nums.size()) { auto a5 = nums[i]; auto b5 = nums[j]; if (a5 - b5 == X) { dump(a5, b5); cout << vtbl[a5] << " " << vtbl[b5] << endl; return 0; } } } assert(0); return 0; }
// https://atcoder.jp/contests/abc166/tasks/abc166_d #include <bits/stdc++.h> #if LOCAL #include "dump.hpp" #else #define dump(...) #endif using namespace std; using ll = long long; const ll LINF = 0x1fffffffffffffff; #define FOR(i, a, b) for (ll i = (a); i < static_cast<ll>(b); ++i) #define REP(i, n) FOR(i, 0, n) 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 (b < a) { a = b; return 1; } return 0; } int main() { ll X; cin >> X; unordered_map<ll, ll> vtbl; vector<ll> nums; { ll i = 0; while (true) { auto i5 = i * i * i * i * i; if (i5 < 0) break; if (i5 > LINF) break; vtbl[i5] = i; vtbl[-i5] = -i; nums.push_back(i5); nums.push_back(-i5); dump(i5); ++i; } } dump(nums.size()) FOR(i, 0, nums.size()) { FOR(j, 0, nums.size()) { auto a5 = nums[i]; auto b5 = nums[j]; if (a5 - b5 == X) { dump(a5, b5); cout << vtbl[a5] << " " << vtbl[b5] << endl; return 0; } } } assert(0); return 0; }
replace
35
36
35
38
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using mii = map<int, int>; using mll = map<ll, ll>; using vi = vector<int>; using vii = vector<vi>; using vpi = vector<pii>; using vl = vector<ll>; using vll = vector<vl>; using vpl = vector<pll>; using vs = vector<string>; int main() { ll x; cin >> x; ll half = sqrtl(x); ll bai; for (ll i = half;; i--) { if (x % i == 0) { bai = i; break; } } for (ll i = 0;; i++) { ll j = i - bai; if (i * i * i * i + i * i * i * j + i * i * j * j + i * j * j * j + j * j * j * j == x / bai) { cout << i << " " << j << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using mii = map<int, int>; using mll = map<ll, ll>; using vi = vector<int>; using vii = vector<vi>; using vpi = vector<pii>; using vl = vector<ll>; using vll = vector<vl>; using vpl = vector<pll>; using vs = vector<string>; int main() { ll x; cin >> x; for (ll i = -120; i <= 120; i++) { for (ll j = -120; j <= 120; j++) { if (i * i * i * i * i - j * j * j * j * j == x) { cout << i << " " << j << endl; return 0; } } } return 0; }
replace
18
33
18
24
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for (ll i = 0; i < n; i++) #define INF 9223372036854775807 #define all(x) (x).begin(), (x).end() ll ts = 1000000007; int five(ll n) { return n * n * n * n * n; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll x; cin >> x; bool can = false; for (ll i = 0; i <= x; i++) { for (ll j = 0; j >= i * -1; j--) { if (i - j != 0 && x % (i - j) == 0) { if (five(i) - five(j) == x) { cout << i << " " << j << "\n"; can = true; break; } } } if (can) { break; } } }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i, n) for (ll i = 0; i < n; i++) #define INF 9223372036854775807 #define all(x) (x).begin(), (x).end() ll ts = 1000000007; int five(ll n) { return n * n * n * n * n; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll x; cin >> x; bool can = false; for (ll i = -118; i <= 119; i++) { for (ll j = -118; j <= 119; j++) { if (i - j != 0 && x % (i - j) == 0) { if (five(i) - five(j) == x) { cout << i << " " << j << "\n"; can = true; break; } } } if (can) { break; } } }
replace
20
22
20
22
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x; cin >> x; int a = 0, b = 0; long long a_s = 0, b_s = 0; for (; a_s <= x; a++) { a_s = pow(a, 5); } a = a - 2; a_s = pow(a, 5); for (; a_s - b_s != x; b--) { b_s = pow(b, 5); } b_s = pow(b, 5); if (a_s - b_s < x) { cout << a << " " << b - 1; } else if (a_s - b_s == x) { cout << a << " " << b; } else { cout << a << " " << b + 1; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x; cin >> x; long long a, b; for (a = -1000; a <= 1000; a++) { for (b = 1000; b >= -1000; b--) { if (pow(a, 5) - pow(b, 5) == x) { cout << a << " " << b; return 0; } } } return 0; }
replace
8
25
8
16
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int64_t X; cin >> X; bool finished = true; for (int64_t i = 0; i < 10000; i++) { for (int64_t j = i; j < 10000; j++) { if (pow(i, 5) + pow(j, 5) == X) { cout << i << " -" << j; finished = false; break; } else if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j; finished = false; break; } } if (finished == false) break; } }
#include <bits/stdc++.h> using namespace std; int main() { int64_t X; cin >> X; bool finished = true; for (int64_t i = 0; i < 120; i++) { for (int64_t j = 0; j < 120; j++) { if (pow(i, 5) + pow(j, 5) == X) { cout << i << " -" << j; finished = false; break; } else if (pow(i, 5) - pow(j, 5) == X) { cout << i << " " << j; finished = false; break; } } if (finished == false) break; } }
replace
7
9
7
9
TLE
p02690
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<long long> vll; #define left(x) (x << 1) #define right(x) (x << 1) + 1 #define mid(l, r) ((l + r) >> 1) #define mp make_pair #define pb push_back #define all(a) a.begin(), a.end() #define debug(x) \ { cerr << #x << " = " << x << "\n"; } #define debug2(x, y) \ { cerr << #x << " = " << x << ", " << #y << " = " << y << "\n"; } #define debug3(x, y, z) \ { \ cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z \ << " = " << z << "\n"; \ } #define debug4(x, y, z, w) \ { \ cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z \ << " = " << z << ", " << #w << " = " << w << "\n"; \ } #define ss second #define ff first #define m0(x) memset(x, 0, sizeof(x)) template <typename T> T min_(T a, T b) { return a > b ? b : a; } template <typename T, typename... Ts> T min_(T first, Ts... last) { return min_(first, min_(last...)); } template <typename T> T max_(T a, T b) { return a > b ? a : b; } template <typename T, typename... Ts> T max_(T first, Ts... last) { return max_(first, min_(last...)); } template <class T, class S> std::ostream &operator<<(std::ostream &os, const std::pair<T, S> &t) { os << "(" << t.first << ", " << t.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) { out << "["; size_t last = v.size() - 1; for (size_t i = 0; i < v.size(); ++i) { out << v[i]; if (i != last) out << ", "; } out << "]"; return out; } const int mod = 1e9 + 7; ll pwr(ll base, ll p) { ll ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const long double PI = (long double)(3.1415926535897932384626433832795); const ll mx_ll = numeric_limits<ll>::max(); const int mx_int = numeric_limits<int>::max(); const int maxn = 1e6; double nthRoot(int A, int N) { double xPre = rand() % 10; double eps = 1e-3; double delX = mx_int; double xK; while (delX > eps) { xK = ((N - 1.0) * xPre + (double)A / pow(xPre, N - 1)) / (double)N; delX = abs(xK - xPre); xPre = xK; } return xK; } const double EPS = 0.000001; bool double_is_int(double trouble) { double absolute = abs(trouble); // debug2(absolute, floor(absolute)); return (fabs(absolute - floor(absolute)) < EPS); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); map<ll, pll> mp; for (ll a = -1000; a <= 1000; ++a) { for (ll b = -1000; b <= 1000; ++b) { ll a5 = a * a * a * a * a; ll b5 = b * b * b * b * b; mp[a5 - b5] = {a, b}; } } ll X; cin >> X; if (mp.find(X) != mp.end()) { cout << mp[X].ff << " " << mp[X].ss << endl; return 0; } for (ll i = 0; i <= 1000; ++i) { ll a5 = i * i * i * i * i; ll t2 = a5 - X; double b = nthRoot(t2, 5); // debug3(a5,t2,b); // debug(double_is_int(b)); if (double_is_int(b)) { cout << i << " " << b << endl; return 0; } } for (ll i = 0; i >= -1000; --i) { ll a5 = i * i * i * i * i; ll t2 = a5 - X; double b = nthRoot(t2, 5); // debug3(a5,t2,b); // debug(double_is_int(b)); if (double_is_int(b)) { cout << i << " " << b << endl; return 0; } } assert(X == -1); // cout << a << " " << b << endl; return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<long long> vll; #define left(x) (x << 1) #define right(x) (x << 1) + 1 #define mid(l, r) ((l + r) >> 1) #define mp make_pair #define pb push_back #define all(a) a.begin(), a.end() #define debug(x) \ { cerr << #x << " = " << x << "\n"; } #define debug2(x, y) \ { cerr << #x << " = " << x << ", " << #y << " = " << y << "\n"; } #define debug3(x, y, z) \ { \ cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z \ << " = " << z << "\n"; \ } #define debug4(x, y, z, w) \ { \ cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z \ << " = " << z << ", " << #w << " = " << w << "\n"; \ } #define ss second #define ff first #define m0(x) memset(x, 0, sizeof(x)) template <typename T> T min_(T a, T b) { return a > b ? b : a; } template <typename T, typename... Ts> T min_(T first, Ts... last) { return min_(first, min_(last...)); } template <typename T> T max_(T a, T b) { return a > b ? a : b; } template <typename T, typename... Ts> T max_(T first, Ts... last) { return max_(first, min_(last...)); } template <class T, class S> std::ostream &operator<<(std::ostream &os, const std::pair<T, S> &t) { os << "(" << t.first << ", " << t.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) { out << "["; size_t last = v.size() - 1; for (size_t i = 0; i < v.size(); ++i) { out << v[i]; if (i != last) out << ", "; } out << "]"; return out; } const int mod = 1e9 + 7; ll pwr(ll base, ll p) { ll ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const long double PI = (long double)(3.1415926535897932384626433832795); const ll mx_ll = numeric_limits<ll>::max(); const int mx_int = numeric_limits<int>::max(); const int maxn = 1e6; double nthRoot(int A, int N) { double xPre = rand() % 10; double eps = 1e-3; double delX = mx_int; double xK; while (delX > eps) { xK = ((N - 1.0) * xPre + (double)A / pow(xPre, N - 1)) / (double)N; delX = abs(xK - xPre); xPre = xK; } return xK; } const double EPS = 0.000001; bool double_is_int(double trouble) { double absolute = abs(trouble); // debug2(absolute, floor(absolute)); return (fabs(absolute - floor(absolute)) < EPS); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); map<ll, pll> mp; for (ll a = -500; a <= 500; ++a) { for (ll b = -500; b <= 500; ++b) { ll a5 = a * a * a * a * a; ll b5 = b * b * b * b * b; mp[a5 - b5] = {a, b}; } } ll X; cin >> X; if (mp.find(X) != mp.end()) { cout << mp[X].ff << " " << mp[X].ss << endl; return 0; } for (ll i = 0; i <= 1000; ++i) { ll a5 = i * i * i * i * i; ll t2 = a5 - X; double b = nthRoot(t2, 5); // debug3(a5,t2,b); // debug(double_is_int(b)); if (double_is_int(b)) { cout << i << " " << b << endl; return 0; } } for (ll i = 0; i >= -1000; --i) { ll a5 = i * i * i * i * i; ll t2 = a5 - X; double b = nthRoot(t2, 5); // debug3(a5,t2,b); // debug(double_is_int(b)); if (double_is_int(b)) { cout << i << " " << b << endl; return 0; } } assert(X == -1); // cout << a << " " << b << endl; return 0; }
replace
131
133
131
133
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back const int maxn = 10000; const int INF32 = 1'050'000'000; const long long INF64 = 4'000'000'000'000'000'000; const int MOD7 = 1'000'000'007; const int MOD9 = 1'000'000'009; const int mod = MOD7; void ERROR(int num) { printf("ERROR%d!\n", num); } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1}; int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1}; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll X; cin >> X; map<ll, int> Map; vector<ll> vec; ll front = 0; for (ll i = 0;; i++) { int v = pow(i, 5); // if(i>0 && v-front>X) break; if (i > 0 && v - front > X) break; Map[v] = 1; vec.pb(v); front = v; } ll A = -33, ans_B = -33; for (ll i = 0; i < vec.size(); i++) { ll v = vec[i]; ll res1 = X + v; ll res2 = X - v; if (res2 < 0) res2 = res2 * (-1); if (Map[res1] == 1) { A = res1; ans_B = i; // cout << "B1 " << ans_B << endl; break; } else if (Map[res2] == 1) { A = res2; ans_B = -(i); // cout << "B2 " << ans_B << endl; break; } } // cout << A << endl; for (ll i = 0; i < vec.size(); i++) { if (vec[i] == A) { cout << i << " "; break; } } cout << ans_B << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back const int maxn = 10000; const int INF32 = 1'050'000'000; const long long INF64 = 4'000'000'000'000'000'000; const int MOD7 = 1'000'000'007; const int MOD9 = 1'000'000'009; const int mod = MOD7; void ERROR(int num) { printf("ERROR%d!\n", num); } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1}; int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1}; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll X; cin >> X; map<ll, int> Map; vector<ll> vec; ll front = 0; for (ll i = 0;; i++) { ll v = pow(i, 5); if (i > 0 && v - front > X) break; Map[v] = 1; vec.pb(v); front = v; } ll A = -33, ans_B = -33; for (ll i = 0; i < vec.size(); i++) { ll v = vec[i]; ll res1 = X + v; ll res2 = X - v; if (res2 < 0) res2 = res2 * (-1); if (Map[res1] == 1) { A = res1; ans_B = i; // cout << "B1 " << ans_B << endl; break; } else if (Map[res2] == 1) { A = res2; ans_B = -(i); // cout << "B2 " << ans_B << endl; break; } } // cout << A << endl; for (ll i = 0; i < vec.size(); i++) { if (vec[i] == A) { cout << i << " "; break; } } cout << ans_B << endl; }
replace
29
31
29
30
TLE
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = m; i < n; i++) #define rep(i, n) REP(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define dup(x, y) (((x) + (y)-1) / (y)) #define PI 3.14159265359 typedef long long LL; const LL MOD = 1e9 + 7; const LL LLINF = 1LL << 60; const int INF = 1 << 30; class UnionFind { public: // rank:それぞれの木の深さ vector<int> rank; // p:ポインタ的な配列 vector<int> p; UnionFind() {} UnionFind(int size) { rank.resize(size, 0); p.resize(size, 0); // 最初は、全ての値は別の木に属するようにする //{0},{1},{2},...といった数字一つのみを持つ木が作られる for (int i = 0; i < size; i++) { makeSet(i); } }; // ただ一つの要素xを持つ木を作成する void makeSet(int x) { p[x] = x; rank[x] = 0; } // 要素xが属する木のルートノードの値を求める int findSet(int x) { // xがルートノードでないならポインタがさしている先を再帰的に探索する // ルートノードならreturnする if (x != p[x]) { // ここで最終的に返ってくるのはルートノードの値であるため、探索中に経由したすべてのノードのポインタはルートノードへとつながる。 p[x] = findSet(p[x]); } return p[x]; } // xとyが同じ木に属しているか判定する bool isSame(int x, int y) { return findSet(x) == findSet(y); } // xを要素に持つ木とyを要素に持つ木を統合する void unite(int x, int y) { link(findSet(x), findSet(y)); } private: // xを根に持つ木とyを根に持つ木を統合する void link(int x, int y) { // なるべく木が深くならないように、rankが小さい方をrankが大きい方へ統合する if (rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; // 木の深さが同じだったらどうしても一段深くなってしまう if (rank[x] == rank[y]) { rank[y]++; } } } }; const int MOD_NUM = 2; // base : 9973 class RollingHash { vector<LL> hash[MOD_NUM]; vector<LL> mod = {999999937LL, 1000000007LL}; LL base = 9973; public: RollingHash(string s) { initialize(s); } vector<LL> getHashNum(int left, int right) { vector<LL> res(MOD_NUM); for (int i = 0; i < MOD_NUM; i++) { res[i] = ((hash[i][right] - hash[i][left] * this->mpower(base, right - left, mod[i])) % mod[i] + mod[i]) % mod[i]; } return res; } private: void initialize(string s) { for (int i = 0; i < MOD_NUM; i++) { hash[i].assign(s.size() + 1, 0); for (int j = 0; j < s.size(); j++) { hash[i][j + 1] = (hash[i][j] * base + s[j]) % mod[i]; } } } LL mpower(LL x, LL n, LL mod) { if (n == 0) { return 1; } else if (n % 2 == 0) { return mpower(x * x % mod, n / 2, mod); } else { return x * mpower(x, n - 1, mod) % mod; } } }; template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline T lcm(T x, T y) { return x / __gcd(x, y) * y; } template <class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; } template <class T> inline T mpower(T x, T n) { if (n == 0) { return 1; } else if (n % 2 == 0) { return mpower(x * x % MOD, n / 2); } else { return x * mpower(x, n - 1) % MOD; } } template <class T> inline T q_power(T x, T n) { if (n == 0) { return 1; } else if (n % 2 == 0) { return q_power(x * x, n / 2); } else { return x * q_power(x, n - 1); } } LL mfrac(LL x) { LL res = 1; for (LL i = x; i >= 1; i--) { res *= i; res %= MOD; } return res; } int main() { LL X; cin >> X; for (LL A = -100; A <= 100; A++) { for (LL B = -100; B <= 100; B++) { if (LL(pow(A, 5LL)) - LL(pow(B, 5LL)) == X) { cout << A << " " << B << endl; return 0; } } } return 1; }
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = m; i < n; i++) #define rep(i, n) REP(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define dup(x, y) (((x) + (y)-1) / (y)) #define PI 3.14159265359 typedef long long LL; const LL MOD = 1e9 + 7; const LL LLINF = 1LL << 60; const int INF = 1 << 30; class UnionFind { public: // rank:それぞれの木の深さ vector<int> rank; // p:ポインタ的な配列 vector<int> p; UnionFind() {} UnionFind(int size) { rank.resize(size, 0); p.resize(size, 0); // 最初は、全ての値は別の木に属するようにする //{0},{1},{2},...といった数字一つのみを持つ木が作られる for (int i = 0; i < size; i++) { makeSet(i); } }; // ただ一つの要素xを持つ木を作成する void makeSet(int x) { p[x] = x; rank[x] = 0; } // 要素xが属する木のルートノードの値を求める int findSet(int x) { // xがルートノードでないならポインタがさしている先を再帰的に探索する // ルートノードならreturnする if (x != p[x]) { // ここで最終的に返ってくるのはルートノードの値であるため、探索中に経由したすべてのノードのポインタはルートノードへとつながる。 p[x] = findSet(p[x]); } return p[x]; } // xとyが同じ木に属しているか判定する bool isSame(int x, int y) { return findSet(x) == findSet(y); } // xを要素に持つ木とyを要素に持つ木を統合する void unite(int x, int y) { link(findSet(x), findSet(y)); } private: // xを根に持つ木とyを根に持つ木を統合する void link(int x, int y) { // なるべく木が深くならないように、rankが小さい方をrankが大きい方へ統合する if (rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; // 木の深さが同じだったらどうしても一段深くなってしまう if (rank[x] == rank[y]) { rank[y]++; } } } }; const int MOD_NUM = 2; // base : 9973 class RollingHash { vector<LL> hash[MOD_NUM]; vector<LL> mod = {999999937LL, 1000000007LL}; LL base = 9973; public: RollingHash(string s) { initialize(s); } vector<LL> getHashNum(int left, int right) { vector<LL> res(MOD_NUM); for (int i = 0; i < MOD_NUM; i++) { res[i] = ((hash[i][right] - hash[i][left] * this->mpower(base, right - left, mod[i])) % mod[i] + mod[i]) % mod[i]; } return res; } private: void initialize(string s) { for (int i = 0; i < MOD_NUM; i++) { hash[i].assign(s.size() + 1, 0); for (int j = 0; j < s.size(); j++) { hash[i][j + 1] = (hash[i][j] * base + s[j]) % mod[i]; } } } LL mpower(LL x, LL n, LL mod) { if (n == 0) { return 1; } else if (n % 2 == 0) { return mpower(x * x % mod, n / 2, mod); } else { return x * mpower(x, n - 1, mod) % mod; } } }; template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline T lcm(T x, T y) { return x / __gcd(x, y) * y; } template <class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; } template <class T> inline T mpower(T x, T n) { if (n == 0) { return 1; } else if (n % 2 == 0) { return mpower(x * x % MOD, n / 2); } else { return x * mpower(x, n - 1) % MOD; } } template <class T> inline T q_power(T x, T n) { if (n == 0) { return 1; } else if (n % 2 == 0) { return q_power(x * x, n / 2); } else { return x * q_power(x, n - 1); } } LL mfrac(LL x) { LL res = 1; for (LL i = x; i >= 1; i--) { res *= i; res %= MOD; } return res; } int main() { LL X; cin >> X; for (LL A = -300; A <= 300; A++) { for (LL B = -300; B <= 300; B++) { if ((A * A * A * A * A - B * B * B * B * B) == X) { cout << A << " " << B << endl; return 0; } } } return 1; }
replace
164
167
164
167
0
p02690
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, b) for (int(i) = a; (i) < (b); (i)++) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long int; const int inf = 1001001000; const long long int Inf = 1001001001001001000; void print(vector<vector<int>> a) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a[i].size(); j++) { cout << a[i][j] << " "; } cout << endl; } } void print(vector<vector<long long int>> a) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a[i].size(); j++) { cout << a[i][j] << " "; } cout << endl; } } void print(vector<int> a) { int n = a.size(); for (int j = 0; j < n; j++) { if (j != n - 1) cout << a[j] << " "; else cout << a[j] << endl; } } void print(vector<long long int> a) { int n = a.size(); for (int j = 0; j < n; j++) { if (j != n - 1) cout << a[j] << " "; else cout << a[j] << endl; } } void print(set<int> a) { for (auto x : a) cout << x << " "; cout << endl; } // 繰り返し2乗法を用いたべき乗.x^nを返す. long long int pow_(long long int x, long long int n) { long long int res = 1; while (n) { if (n & 1) { res *= x; } n >>= 1; x = x * x; } return res; } int main() { ll x; cin >> x; for (ll a = -70; a < 70; a++) { for (ll b = -70; b < 70; b++) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } assert(false); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, b) for (int(i) = a; (i) < (b); (i)++) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long int; const int inf = 1001001000; const long long int Inf = 1001001001001001000; void print(vector<vector<int>> a) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a[i].size(); j++) { cout << a[i][j] << " "; } cout << endl; } } void print(vector<vector<long long int>> a) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a[i].size(); j++) { cout << a[i][j] << " "; } cout << endl; } } void print(vector<int> a) { int n = a.size(); for (int j = 0; j < n; j++) { if (j != n - 1) cout << a[j] << " "; else cout << a[j] << endl; } } void print(vector<long long int> a) { int n = a.size(); for (int j = 0; j < n; j++) { if (j != n - 1) cout << a[j] << " "; else cout << a[j] << endl; } } void print(set<int> a) { for (auto x : a) cout << x << " "; cout << endl; } // 繰り返し2乗法を用いたべき乗.x^nを返す. long long int pow_(long long int x, long long int n) { long long int res = 1; while (n) { if (n & 1) { res *= x; } n >>= 1; x = x * x; } return res; } int main() { ll x; cin >> x; int y = 1000; for (ll a = -y; a < y; a++) { for (ll b = -y; b < y; b++) { if (a * a * a * a * a - b * b * b * b * b == x) { cout << a << " " << b << endl; return 0; } } } assert(false); return 0; }
replace
86
88
86
89
0
p02690
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } #define INF 1 << 30 int t[100][100]; int main() { ll X, l, r, k, m; cin >> X; k = (ll)sqrt(X); rep(i, 1ll, k + 1) { if (X % i == 0) { rep(l, 0ll, X) { if (X % (2 * l - i)) continue; if (power(l, 5) - power(l - i, 5) == X) { printf("%lld %lld\n", l, l - i); return 0; } } } } return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } #define INF 1 << 30 int t[100][100]; int main() { ll X, l, r, k, m; cin >> X; k = (ll)sqrt(X); rep(i, 1ll, k + 1) { if (X % i == 0) { rep(l, 0ll, X) { r = power(l, 5) - power(l - i, 5); if (l >= i && r > X) break; if (r == X) { printf("%lld %lld\n", l, l - i); return 0; } } } } return 0; }
replace
47
50
47
51
0
p02690
C++
Runtime Error
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cstdio> #include <ctime> #include <ctype.h> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <unistd.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define debug(name) DEBUG(#name, (name)) template <typename T> void DEBUG(string label, T value) { cerr << "[" << label << " = " << value << "]\n"; } void solve() { ll x; cin >> x; const int N = 72; vector<ll> table(N + 1); for (int i = 0; i <= N; ++i) { table[i] = 1LL * i * i * i * i * i; } for (int i = 0; i <= N; ++i) { for (int j = 0; j <= N; ++j) { if (table[i] + table[j] == x) { cout << i << " " << -j << endl; return; } if (table[i] - table[j] == x) { cout << i << " " << j << endl; return; } } } assert(0); } int main(int argv, char **argc) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cstdio> #include <ctime> #include <ctype.h> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <unistd.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define debug(name) DEBUG(#name, (name)) template <typename T> void DEBUG(string label, T value) { cerr << "[" << label << " = " << value << "]\n"; } void solve() { ll x; cin >> x; const int N = 3980; vector<ll> table(N + 1); for (int i = 0; i <= N; ++i) { table[i] = 1LL * i * i * i * i * i; } for (int i = 0; i <= N; ++i) { for (int j = 0; j <= N; ++j) { if (table[i] + table[j] == x) { cout << i << " " << -j << endl; return; } if (table[i] - table[j] == x) { cout << i << " " << j << endl; return; } } } assert(0); } int main(int argv, char **argc) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
replace
40
41
40
41
0
p02690
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const long long N = 9000; long long arr[N] = {}; int main() { long long x; cin >> x; if (x == 0) { cout << "0 0\n"; return 0; } long long a, b; for (long long i = 1; i < N; i++) for (long long j = i + 1; j < N; j++) { a = j, b = i; long long t = a * a + b * b; if (a != b && x % (a - b) == 0) if (x / (a - b) - t * t == a * b * (t - a * b)) { cout << a << " " << b; return 0; } a = j, b = -i; if (x % (a - b) == 0) if (x / (a - b) - t * t == a * b * (t - a * b)) { cout << a << " " << b; return 0; } } return -1; }
#include <bits/stdc++.h> using namespace std; const long long N = 9000; long long arr[N] = {}; int main() { long long x; cin >> x; if (x == 0) { cout << "0 0\n"; return 0; } if (x == 1) { cout << "1 0\n"; return 0; } long long a, b; for (long long i = 1; i < N; i++) for (long long j = i + 1; j < N; j++) { a = j, b = i; long long t = a * a + b * b; if (a != b && x % (a - b) == 0) if (x / (a - b) - t * t == a * b * (t - a * b)) { cout << a << " " << b; return 0; } a = j, b = -i; if (x % (a - b) == 0) if (x / (a - b) - t * t == a * b * (t - a * b)) { cout << a << " " << b; return 0; } } return -1; }
insert
9
9
9
13
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <cstdlib> #include <iostream> #include <vector> using namespace std; const long long INF = 1LL << 60; int main() { int X; cin >> X; bool owari = 0; for (int i = -10000; i <= 10000; i++) { for (int j = -10000; j <= 10000; j++) { int A = pow(i, 5); int B = pow(j, 5); if (A - B == X) { cout << i << " " << j << endl; owari = 1; break; } } if (owari) break; } }
#include <bits/stdc++.h> #include <cstdlib> #include <iostream> #include <vector> using namespace std; const long long INF = 1LL << 60; int main() { int X; cin >> X; bool owari = 0; for (int i = -120; i <= 120; i++) { for (int j = -120; j <= 120; j++) { long long A = pow(i, 5); long long B = pow(j, 5); if (A - B == X) { cout << i << " " << j << endl; owari = 1; break; } } if (owari) break; } }
replace
11
15
11
15
TLE
p02690
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n' const int N = 1e6; int main() { ios_base::sync_with_stdio(0); ll a, b, n, x, T, cas = 0; cin >> x; a = 0, b = 0; for (ll i = -100; i <= 100; ++i) { ll p = i * i * i * i * i; ll q = p - x; ll t = q; // cerr<<p<<" "<<q; int neg = 0; if (q < 0) { neg = 1; q *= -1; } ll r = pow(q, 1.0 / 5); if (neg) r *= -1; // cerr<<r<<endl; if (r * r * r * r * r == t) { a = i, b = r; // if(neg) b*=-1; break; } } if (a == 0 && b == 0) assert(a != 0); cout << a << " " << b << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n' const int N = 1e6; int main() { ios_base::sync_with_stdio(0); ll a, b, n, x, T, cas = 0; cin >> x; a = 0, b = 0; for (ll i = -1000; i <= 1000; ++i) { ll p = i * i * i * i * i; ll q = p - x; ll t = q; // cerr<<p<<" "<<q; int neg = 0; if (q < 0) { neg = 1; q *= -1; } ll r = pow(q, 1.0 / 5); if (neg) r *= -1; // cerr<<r<<endl; if (r * r * r * r * r == t) { a = i, b = r; // if(neg) b*=-1; break; } } if (a == 0 && b == 0) assert(a != 0); cout << a << " " << b << endl; return 0; }
replace
11
12
11
12
0
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using ll = long long; using namespace std; ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; } int main() { ll x; cin >> x; for (ll i = -1e4; i <= 1e4; i++) { for (ll j = -1e4; j <= 1e4; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } }
#include <bits/stdc++.h> using ll = long long; using namespace std; ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; } int main() { ll x; cin >> x; for (ll i = -1e3; i <= 1e3; i++) { for (ll j = -1e3; j <= 1e3; j++) { if (pow(i, 5) - pow(j, 5) == x) { cout << i << " " << j << endl; return 0; } } } }
replace
7
9
7
9
TLE
p02690
C++
Time Limit Exceeded
#include <iostream> #include <numeric> #include <vector> using namespace std; int X; vector<int> factor(int n) { vector<int> x; for (int i = 2; i <= n; i++) { while (n % i == 0) { x.push_back(i); n /= i; } } return x; } int pow(int a, int b) { int ans = 1; while (b--) { ans *= a; } return ans; } void solve() { vector<int> f = factor(X); int bit = 0; while (1) { bit++; if (bit > pow(2, f.size())) { break; } int x = 1; for (int i = 0; i < f.size(); i++) { if (bit & (2 << i)) { x *= f[i]; } } int y = X / x; long long a = x, b; if (x > y || a > 177) { continue; } while (1) { a--; b = a - x; if (a - b < 0) { break; } if (a * a * a * a * a - b * b * b * b * b == X) { cout << a << " " << b << endl; return; } } } } int main() { cin >> X; solve(); return 0; }
#include <iostream> #include <numeric> #include <vector> using namespace std; int X; vector<int> factor(int n) { vector<int> x; for (int i = 2; i <= n; i++) { while (n % i == 0) { x.push_back(i); n /= i; } } return x; } int pow(int a, int b) { int ans = 1; while (b--) { ans *= a; } return ans; } void solve() { vector<int> f = factor(X); int bit = 0; for (long long a = -178; a <= 178; a++) { for (long long b = -178; b <= 178; b++) { if (a * a * a * a * a - b * b * b * b * b == X) { cout << a << " " << b << endl; return; } } } } int main() { cin >> X; solve(); return 0; }
replace
31
55
31
33
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) typedef long long ll; using namespace std; int main() { ll x; cin >> x; ll root = pow(x, 1 / 5); ll ans_a = 0; ll ans_b = 0; bool flg = false; rep(i, 100000) { rep(j, 100000) { // if(x>=pow(root+i, 5)-pow(j, 5) && x<=pow(root+i, 5)-pow(-j, 5))break; if (x == pow(root + i, 5) - pow(j, 5)) { ans_a = root + i; ans_b = j; flg = true; } if (x == pow(root + i, 5) - pow(-j, 5)) { ans_a = root + i; ans_b = -j; flg = true; } if (x == pow(root - i, 5) - pow(j, 5)) { ans_a = root - i; ans_b = j; flg = true; } if (x == pow(root - i, 5) - pow(-j, 5)) { ans_a = root - i; ans_b = -j; flg = true; } if (flg) break; } if (flg) break; } cout << ans_a << " " << ans_b << endl; }
#include <bits/stdc++.h> #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) typedef long long ll; using namespace std; int main() { ll x; cin >> x; ll root = pow(x, 1 / 5); ll ans_a = 0; ll ans_b = 0; bool flg = false; rep(i, 10000) { rep(j, 10000) { if (x >= pow(root + i, 5) - pow(j, 5) && x <= pow(root - i, 5) - pow(-j, 5)) break; if (x == pow(root + i, 5) - pow(j, 5)) { ans_a = root + i; ans_b = j; flg = true; } if (x == pow(root + i, 5) - pow(-j, 5)) { ans_a = root + i; ans_b = -j; flg = true; } if (x == pow(root - i, 5) - pow(j, 5)) { ans_a = root - i; ans_b = j; flg = true; } if (x == pow(root - i, 5) - pow(-j, 5)) { ans_a = root - i; ans_b = -j; flg = true; } if (flg) break; } if (flg) break; } cout << ans_a << " " << ans_b << endl; }
replace
15
18
15
20
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x; cin >> x; ll ansa = 0, ansb = 0; for (ll i = 0; i < 10000; i++) { for (ll j = 0; j < 10000; j++) { if (pow(i, 5) - pow(j, 5) == x) { ansa = i; ansb = j; break; } else if (pow(i, 5) + pow(j, 5) == x) { ansa = i; ansb = 0 - j; break; } } } cout << ansa << ' ' << ansb << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x; cin >> x; ll ansa = 0, ansb = 0; for (ll i = 0; i < 1000; i++) { for (ll j = 0; j < 1000; j++) { if (pow(i, 5) - pow(j, 5) == x) { ansa = i; ansb = j; break; } else if (pow(i, 5) + pow(j, 5) == x) { ansa = i; ansb = 0 - j; break; } } } cout << ansa << ' ' << ansb << endl; }
replace
9
11
9
11
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long x; cin >> x; long long mi, mi2; for (int i = 1; i < 40000; i++) { if (x % i == 0) { long long y = x / i; for (long long j = 0; j < y; j++) { mi = j - i; mi2 = mi * mi; if (j * j * j * j + j * j * j * mi + j * j * mi2 + j * mi * mi2 + mi2 * mi2 == y) { printf("%lld %lld\n", j, mi); return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { long long x; cin >> x; long long mi, mi2; for (int i = 1; i < 40000; i++) { if (x % i == 0) { long long y = x / i; long long start = sqrt(sqrt(y)); for (long long j = start; j > 0; j--) { mi = j - i; mi2 = mi * mi; if (j * j * j * j + j * j * j * mi + j * j * mi2 + j * mi * mi2 + mi2 * mi2 == y) { printf("%lld %lld\n", j, mi); return 0; } } } } }
replace
10
11
10
12
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int #define set_bits(a) __builtin_popcount(a) #define pb push_back #define pf push_front #define mod 1000000007 #define M 998244353 #define fi first #define se second #define endl '\n' #define INF 1e18 #define PI 3.14159265358979323846 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); int main() { ll x; cin >> x; vector<ll> v; ll i; map<ll, ll> m; map<ll, ll> mp; for (i = -1000000; i <= 1000000; i++) { ll x = i * i * i * i * i; mp[x]++; v.pb(x); m[x] = i; } ll a1, a2; if (x == 1) { cout << "0" << " " << "-1" << endl; exit(0); } for (i = 0; i < v.size(); i++) { ll p = v[i] - x; if (mp.find(p) != mp.end()) { a1 = m[v[i]]; a2 = m[p]; break; } } cout << a1 << " " << a2 << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define set_bits(a) __builtin_popcount(a) #define pb push_back #define pf push_front #define mod 1000000007 #define M 998244353 #define fi first #define se second #define endl '\n' #define INF 1e18 #define PI 3.14159265358979323846 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); int main() { ll x; cin >> x; vector<ll> v; ll i; map<ll, ll> m; map<ll, ll> mp; for (i = -100000; i <= 100000; i++) { ll x = i * i * i * i * i; mp[x]++; v.pb(x); m[x] = i; } ll a1, a2; if (x == 1) { cout << "0" << " " << "-1" << endl; exit(0); } for (i = 0; i < v.size(); i++) { ll p = v[i] - x; if (mp.find(p) != mp.end()) { a1 = m[v[i]]; a2 = m[p]; break; } } cout << a1 << " " << a2 << endl; }
replace
26
27
26
27
TLE
p02690
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll x; cin >> x; ll judge = 0; for (ll i = -10000; i < 10000; i++) { for (ll j = -10000; j < 10000; j++) { ll i5 = pow(i, 5); ll j5 = pow(j, 5); if (i5 - j5 == x) { cout << i << " " << j << endl; judge = 1; break; } } if (judge == 1) { break; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll x; cin >> x; ll judge = 0; for (ll i = -1000; i < 1000; i++) { for (ll j = -1000; j < 1000; j++) { ll i5 = pow(i, 5); ll j5 = pow(j, 5); if (i5 - j5 == x) { cout << i << " " << j << endl; judge = 1; break; } } if (judge == 1) { break; } } }
replace
9
11
9
11
TLE