結果

問題 No.1312 Snake Eyes
ユーザー hiro71687khiro71687k
提出日時 2023-05-06 05:11:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,121 bytes
コンパイル時間 4,529 ms
コンパイル使用メモリ 263,268 KB
実行使用メモリ 19,052 KB
最終ジャッジ日時 2024-05-02 21:22:14
合計ジャッジ時間 10,227 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
18,928 KB
testcase_01 AC 7 ms
18,944 KB
testcase_02 AC 7 ms
18,944 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 6 ms
18,924 KB
testcase_06 AC 7 ms
18,944 KB
testcase_07 AC 7 ms
18,784 KB
testcase_08 AC 7 ms
18,816 KB
testcase_09 WA -
testcase_10 AC 7 ms
18,816 KB
testcase_11 AC 7 ms
18,944 KB
testcase_12 AC 6 ms
18,944 KB
testcase_13 AC 7 ms
18,920 KB
testcase_14 AC 8 ms
18,944 KB
testcase_15 AC 7 ms
18,944 KB
testcase_16 AC 8 ms
18,816 KB
testcase_17 AC 7 ms
18,944 KB
testcase_18 AC 9 ms
18,944 KB
testcase_19 AC 7 ms
18,944 KB
testcase_20 AC 8 ms
18,816 KB
testcase_21 AC 7 ms
18,928 KB
testcase_22 AC 7 ms
18,944 KB
testcase_23 AC 8 ms
18,944 KB
testcase_24 AC 8 ms
18,940 KB
testcase_25 AC 7 ms
18,944 KB
testcase_26 AC 7 ms
18,944 KB
testcase_27 AC 10 ms
18,944 KB
testcase_28 AC 7 ms
18,944 KB
testcase_29 AC 6 ms
18,824 KB
testcase_30 AC 8 ms
18,944 KB
testcase_31 AC 7 ms
18,944 KB
testcase_32 AC 6 ms
18,816 KB
testcase_33 AC 8 ms
18,944 KB
testcase_34 AC 8 ms
18,944 KB
testcase_35 AC 9 ms
18,944 KB
testcase_36 AC 8 ms
18,944 KB
testcase_37 AC 8 ms
18,944 KB
testcase_38 AC 7 ms
18,940 KB
testcase_39 WA -
testcase_40 AC 10 ms
18,928 KB
testcase_41 AC 25 ms
18,944 KB
testcase_42 RE -
testcase_43 WA -
testcase_44 AC 27 ms
18,944 KB
testcase_45 AC 9 ms
18,944 KB
testcase_46 WA -
testcase_47 RE -
testcase_48 AC 27 ms
18,920 KB
testcase_49 AC 33 ms
18,848 KB
testcase_50 RE -
testcase_51 WA -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 WA -
testcase_56 AC 21 ms
18,928 KB
testcase_57 WA -
testcase_58 RE -
testcase_59 AC 15 ms
18,944 KB
testcase_60 WA -
testcase_61 AC 36 ms
18,848 KB
testcase_62 AC 16 ms
18,944 KB
testcase_63 AC 10 ms
18,944 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 8 ms
18,944 KB
testcase_67 AC 8 ms
18,848 KB
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 28 ms
18,944 KB
testcase_77 AC 29 ms
18,920 KB
testcase_78 AC 30 ms
18,944 KB
testcase_79 WA -
testcase_80 RE -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 32 ms
18,944 KB
testcase_84 AC 29 ms
18,944 KB
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=14449999999999999;
ll mod=998244353;
ll modpow(ll x, ll n) {
  if(n==0) return 1;  //再帰の終了条件

  else if(n%2==1) {
    return (x*modpow(x, n-1));  //nが奇数ならnを1ずらす
  }
  else return modpow((x*x), n/2);  //nが偶数ならnが半分になる
}
int main(){
    ll n;
    cin >> n;
    if (n==1)
    {
        cout << 2 << endl;
        return 0;
    }else if (n==2)
    {
        cout << 3 << endl;
        return 0;
    }
    ll ans=n-1;
    vector<ll>y(2000000,1);
    for (ll i = 1; i <=43; i++)
    {
        bool ok=false;
        for (ll j = 2; j <ans; j++)
        {
            y[j]*=j;
            y[j]+=1;
            if (y[j]>n)
            {
                break;
            }
            if (n%y[j]==0&&n/y[j]<j)
            {
                ok=true;
                ans=j;
                break;
            }
        }
        if (!ok)
        {
            break;
        }
    }
    cout << ans << endl;
}
0