結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
![]() |
提出日時 | 2020-12-09 00:14:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 945 bytes |
コンパイル時間 | 1,880 ms |
コンパイル使用メモリ | 172,364 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 22:01:15 |
合計ジャッジ時間 | 4,042 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 WA * 1 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end int main(){ ll n; cin>>n; if(n==1 or n==2){ puts("2"); return 0; } for(ll p=2;p*p<=n;p++){ ll m=n; ll v=m%p; for(;m;m/=p){ if(m%p!=v)goto fail; } cout<<p<<endl; return 0; fail:; } vector<ll> ds; for(ll d=1;d*d<=n;d++)if(n%d==0){ ds.push_back(d); if(d*d!=n)ds.push_back(n/d); } sort(ALL(ds)); for(auto& d:ds)if(d>=3 and n/d<d-1){ cout<<d-1<<endl; return 0; } return 0; }