結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
![]() |
提出日時 | 2020-12-09 01:06:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 2,011 ms |
コンパイル使用メモリ | 191,312 KB |
最終ジャッジ日時 | 2025-01-16 20:19:57 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 32 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"; } 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); } } cout << ans << "\n"; }