結果
| 問題 |
No.1312 Snake Eyes
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2020-12-09 19:59:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 958 bytes |
| コンパイル時間 | 1,749 ms |
| コンパイル使用メモリ | 171,492 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 02:53:23 |
| 合計ジャッジ時間 | 7,926 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 84 WA * 1 |
ソースコード
#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==1){
cout << 2 << endl;
return 0;
}
else if(n==2){
cout << 3 << endl;
return 0;
}
else if(n==6){
cout << 5 << endl;
return 0;
}
ll ans=INF;
for(ll i=1;i<sqrt(n);i++){
if(n%i==0){
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;
}
Haa