結果
問題 | No.1312 Snake Eyes |
ユーザー |
![]() |
提出日時 | 2020-12-09 00:15:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 992 bytes |
コンパイル時間 | 1,475 ms |
コンパイル使用メモリ | 172,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 12:54:23 |
合計ジャッジ時間 | 3,948 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 85 |
ソースコード
#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;}//endint main(){ll n; cin>>n;if(n==1){puts("2");return 0;}if(n==2){puts("3");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;}