結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
![]() |
提出日時 | 2020-12-09 02:55:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,346 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 176,564 KB |
実行使用メモリ | 254,336 KB |
最終ジャッジ日時 | 2024-09-19 00:21:37 |
合計ジャッジ時間 | 36,261 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 59 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vector<ll> > #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; typedef long double ld; typedef complex<double> Complex; const ll INF=1e9+7; const ll inf=INF*INF; const int mod=1e9+7; const ll MAX=100010; const double PI=acos(-1.0); signed main(){ ll n;cin>>n; if(n==2){ cout<<3<<endl; return 0; }else if(n==1){ cout<<2<<endl; return 0; } set<pll>st; ll ans=n-1; REP(i,2,sqrt(n+1)){ ll now=1; ll sum=0; while(sum<=n){ sum+=now; st.insert(mp(sum,-i)); now*=i; } } vector<ll>p(0); REP(i,2,sqrt(n+1)){ if(n%i==0){ p.pb(i); p.pb(n/i); } } rep(i,p.size()){ auto it=st.lower_bound(mp(p[i],-inf)); if(it==st.end()){ continue; } if((*it).first==p[i]&&(*it).se<-n/p[i]){ ans=min(ans,-(*it).se); } } cout<<ans<<endl; }