結果
| 問題 |
No.1312 Snake Eyes
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-12-09 01:10:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,002 bytes |
| コンパイル時間 | 2,198 ms |
| コンパイル使用メモリ | 191,440 KB |
| 最終ジャッジ日時 | 2025-01-16 20:21:06 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 RE * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << (x) << endl;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
if(N==1){
cout << 2 << "\n";
return 0;
}
ll ans = N+1;
if(N>2) ans = N-1;
for(ll i=2;i*i<=N;i++){
ll a = i;
while(true){
a *= i;
ll now = (a-1)/(i-1);
if(now>N) break;
if(N%now==0 && N/now<i) chmin(ans,i);
}
if(N%i==0){
ll n = N/i;
if(n<i-1) chmin(ans,i-1);
n = i;
if(n<N/i-1) chmin(ans,N/i-1);
}
}
cout << ans << "\n";
}
IKyopro