結果

問題 No.1312 Snake Eyes
ユーザー だれだれ
提出日時 2021-12-17 20:35:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,452 bytes
コンパイル時間 3,720 ms
コンパイル使用メモリ 185,868 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2023-10-12 23:45:13
合計ジャッジ時間 9,813 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,488 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,356 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 31 ms
4,348 KB
testcase_24 AC 36 ms
4,352 KB
testcase_25 AC 21 ms
4,352 KB
testcase_26 AC 16 ms
4,352 KB
testcase_27 AC 34 ms
4,348 KB
testcase_28 AC 20 ms
4,352 KB
testcase_29 AC 57 ms
4,348 KB
testcase_30 AC 27 ms
4,352 KB
testcase_31 AC 42 ms
4,352 KB
testcase_32 AC 44 ms
4,352 KB
testcase_33 AC 7 ms
4,348 KB
testcase_34 AC 54 ms
4,352 KB
testcase_35 AC 42 ms
4,348 KB
testcase_36 AC 53 ms
4,348 KB
testcase_37 AC 59 ms
4,356 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_set>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }
inline void YesNo(bool f) { std::cout << (f? "Yes": "No") << std::endl; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

template<class T>
vector<T> div(T x)
{
    vector<T> res;
    for(T i = 1; i * i <= x; i++)
    {
        if(x % i == 0)
        {
            res.push_back(i);
            if(i * i == x) break;
            res.push_back(x / i);
        }
    }
    sort(all(res));
    return res;
}

i64 mypow(i64 a, i64 b){
    i64 res = 1;
    while (b){
        if (b & 1) res *= a;
        a *= a;
        b >>= 1;
    }
    return res;
}

int main(){
    i64 n;
    cin >> n;
    auto z = div(n);
    i64 ans = 1e18;
    for (auto i: z){
        i64 p = n / i - 1;
        if (p > i) chmin(ans, p);
    }
    for (int i = 1; i <= sqrt(n); i++){
        i64 p = 1;
        for (int j = 1; ; j++){
            p += mypow(i, j);
            if (p > n) break;
            if (n % p == 0){
                i64 y = n / p;
                if (y < i) chmin(ans, i);
            }
        }
    }
    cout << ans << endl;
}
0