結果
問題 | No.2253 Ignore Subtle Differences |
ユーザー | nagisa5101 |
提出日時 | 2023-03-24 22:22:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,410 bytes |
コンパイル時間 | 4,401 ms |
コンパイル使用メモリ | 262,844 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-18 17:16:08 |
合計ジャッジ時間 | 4,223 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repll(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep2(i, n, m) for (int i = n; i < (int)(m); i++) #define repll2(i, n, m) for (long long i = n; i < (long long)(m); i++) #define all(v) v.begin(),v.end() using ll=long long; using ld=long double; using vi=vector<int>; using vvi=vector<vi>; using vvvi=vector<vvi>; using vl=vector<ll>; using vvl=vector<vl>; using vvvl=vector<vvl>; using vld=vector<ld>; using vvld=vector<vld>; int dx[8]={1,0,-1,0,1,1,-1,-1}; int dy[8]={0,1,0,-1,1,-1,1,-1}; const double PI = acos(-1); //const ll MOD=1e9+7; //const ll MOD=998244353; const ll INF=(1LL<<60); const int INF2=(1<<30); //using mint=modint1000000007; //using mint=modint998244353; /* prime_factor(n) 入力:整数 n 出力:nの素因数分解 計算量:O(√n)前後 */ template <typename T> vector<pair<T, T>> prime_factor(T n) { vector<pair<T, T>> ret; for (T i = 2; i * i <= n; i++) { if (n % i != 0) continue; T tmp = 0; while (n % i == 0) { tmp++; n /= i; } ret.push_back(make_pair(i, tmp)); } if (n != 1) ret.push_back(make_pair(n, 1)); return ret; } pair<ll,ll> is_square(ll i){ ll low=0,high=i; while(high-low>1){ ll mid=(high+low)/2; if(mid*mid>i)high=mid; else low=mid; } return {(low*low==i),low}; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); int p=-1; /* while(cnt>0){ auto arr=prime_factor(now); int isok=1; for(auto pp:arr){ if(pp.first%4==3){ if(pp.second%2!=0)isok=0; } } if(isok){ if(now+1==p){ cout<<now<<" "<<p<<endl; return 0; } p=now; } now--; } */ /* ll p1=999999961,p2=999999962; for(ll i=1;i<100000;i++){ auto pp=is_square(p1-i*i); if(pp.first){ cout<<i*i<<" "<<p1-i*i<<endl; cout<<i<<" "<<pp.second<<endl; break; } } for(ll i=1;i<100000;i++){ auto pp=is_square(p2-i*i); if(pp.first){ cout<<i*i<<" "<<p2-i*i<<endl; cout<<i<<" "<<pp.second<<endl; break; } }*/ ll now=999999999; now-=now/2; ll cnt=now/2; /* while(cnt){ ll high=now,low=0; while(high-low>1){ ll mid=(high+low)/2; //(now,mid),(mid,now)の距離は? ll d1=now*now+mid*mid; ll d2=(now-mid)*(now-mid)*2; if(d1>d2)high=mid; else low=mid; } ll d1=now*now+low*low; ll d2=(now-low)*(now-low)*2; if(abs(d1-d2)==1){ cout<<now<<" "<<low<<endl; return 0; } d1=now*now+high*high; d2=(now-high)*(now-high)*2; if(abs(d1-d2)==1){ cout<<now<<" "<<high<<endl; return 0; } now--; cnt--; } */ cout<<0<<" "<<0<<endl; cout<<408855776<<" "<<109552575<<endl; cout<<109552575<<" "<<408855776<<endl; return 0; }