結果
問題 | No.1312 Snake Eyes |
ユーザー |
![]() |
提出日時 | 2020-12-09 20:18:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 1,663 ms |
コンパイル使用メモリ | 171,664 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 13:05:42 |
合計ジャッジ時間 | 7,835 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 85 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long int ll;typedef pair<ll,ll> P;typedef vector<ll> VI;typedef vector<VI> VVI;#define REP(i,n) for(int i=0;i<n;i++)#define ALL(v) v.begin(),v.end()constexpr ll MOD=998244353;constexpr ll INF=1e18;int main(){ll n; cin >> n;if(n<=2){cout << n+1 << endl;return 0;}ll ans=INF;for(ll i=1;i<sqrt(n);i++){if(n%i==0){if(log(n)/log(n/i-1)<2)ans=min(ans,n/i-1);}}for(ll i=2;i<=sqrt(n);i++){int m=log(n)/log(i);ll x=n;set<int> st;for(int j=m;j>=0;j--){ll y=pow(i,j);st.insert(x/y);x%=y;}if(st.size()==1){ans=min(ans,i);break;}}cout << ans << endl;return 0;}