結果

問題 No.1312 Snake Eyes
ユーザー rabimearabimea
提出日時 2023-01-25 20:33:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 205,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 05:34:15
合計ジャッジ時間 12,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,376 KB
testcase_01 AC 48 ms
4,376 KB
testcase_02 AC 48 ms
4,376 KB
testcase_03 AC 48 ms
4,380 KB
testcase_04 AC 48 ms
4,380 KB
testcase_05 AC 48 ms
4,376 KB
testcase_06 AC 48 ms
4,376 KB
testcase_07 AC 48 ms
4,376 KB
testcase_08 AC 49 ms
4,376 KB
testcase_09 AC 48 ms
4,380 KB
testcase_10 AC 48 ms
4,380 KB
testcase_11 AC 48 ms
4,376 KB
testcase_12 AC 48 ms
4,376 KB
testcase_13 AC 48 ms
4,376 KB
testcase_14 AC 48 ms
4,376 KB
testcase_15 AC 48 ms
4,380 KB
testcase_16 AC 48 ms
4,380 KB
testcase_17 AC 49 ms
4,380 KB
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 48 ms
4,376 KB
testcase_20 AC 49 ms
4,380 KB
testcase_21 AC 48 ms
4,380 KB
testcase_22 AC 48 ms
4,380 KB
testcase_23 AC 67 ms
4,380 KB
testcase_24 AC 71 ms
4,376 KB
testcase_25 AC 60 ms
4,376 KB
testcase_26 AC 58 ms
4,380 KB
testcase_27 AC 69 ms
4,380 KB
testcase_28 AC 60 ms
4,376 KB
testcase_29 AC 84 ms
4,380 KB
testcase_30 AC 65 ms
4,380 KB
testcase_31 AC 76 ms
4,376 KB
testcase_32 AC 76 ms
4,376 KB
testcase_33 AC 52 ms
4,376 KB
testcase_34 AC 82 ms
4,376 KB
testcase_35 AC 74 ms
4,376 KB
testcase_36 AC 82 ms
4,376 KB
testcase_37 AC 85 ms
4,376 KB
testcase_38 AC 95 ms
4,376 KB
testcase_39 AC 96 ms
4,376 KB
testcase_40 AC 96 ms
4,376 KB
testcase_41 AC 95 ms
4,376 KB
testcase_42 AC 94 ms
4,376 KB
testcase_43 AC 95 ms
4,380 KB
testcase_44 AC 94 ms
4,380 KB
testcase_45 AC 95 ms
4,380 KB
testcase_46 AC 95 ms
4,376 KB
testcase_47 AC 95 ms
4,380 KB
testcase_48 AC 145 ms
4,376 KB
testcase_49 AC 141 ms
4,376 KB
testcase_50 AC 131 ms
4,376 KB
testcase_51 AC 113 ms
4,376 KB
testcase_52 AC 154 ms
4,376 KB
testcase_53 AC 137 ms
4,376 KB
testcase_54 AC 144 ms
4,380 KB
testcase_55 AC 119 ms
4,376 KB
testcase_56 AC 126 ms
4,380 KB
testcase_57 AC 127 ms
4,380 KB
testcase_58 AC 137 ms
4,380 KB
testcase_59 AC 111 ms
4,380 KB
testcase_60 AC 126 ms
4,380 KB
testcase_61 AC 151 ms
4,380 KB
testcase_62 AC 116 ms
4,376 KB
testcase_63 AC 94 ms
4,376 KB
testcase_64 AC 96 ms
4,380 KB
testcase_65 AC 101 ms
4,376 KB
testcase_66 AC 54 ms
4,376 KB
testcase_67 AC 48 ms
4,376 KB
testcase_68 AC 97 ms
4,380 KB
testcase_69 AC 94 ms
4,376 KB
testcase_70 AC 140 ms
4,376 KB
testcase_71 AC 121 ms
4,376 KB
testcase_72 AC 96 ms
4,376 KB
testcase_73 AC 94 ms
4,376 KB
testcase_74 AC 65 ms
4,376 KB
testcase_75 AC 94 ms
4,380 KB
testcase_76 AC 151 ms
4,376 KB
testcase_77 AC 151 ms
4,380 KB
testcase_78 AC 152 ms
4,380 KB
testcase_79 AC 136 ms
4,376 KB
testcase_80 AC 151 ms
4,380 KB
testcase_81 AC 151 ms
4,376 KB
testcase_82 AC 152 ms
4,376 KB
testcase_83 AC 152 ms
4,380 KB
testcase_84 AC 151 ms
4,376 KB
testcase_85 AC 147 ms
4,380 KB
testcase_86 AC 144 ms
4,376 KB
testcase_87 AC 122 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
using vi = vector <int>;
using ll = long long;
using pii = pair <int, int>;
//~ const ll mod = 998244353;
const ll mod = 1e9 + 7;
ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a;
	for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; }

bool check(ll n, ll p) {
	if(p == 0 || p == 1) return 0;
	vector <ll> v;
	while(n) {
		v.pb(n % p);
		n /= p;
	}
	sort(v.begin(), v.end());
	return (v[0] == v.back());
}

int main() {
	ios :: sync_with_stdio(false);
	ll n; cin >> n;
	ll ans = n + 1;
	for(ll i = 2; i <= ll(1e6); i ++)
		if(check(n, i)) ans = min(ans, i);
	
	for(ll i = 1; i * i <= n; i ++) if(n % i == 0) {
		for(ll x : {i - 1, n / i - 1})
			if(check(n, x)) ans = min(ans, x);
	}
	
	cout << ans << '\n';
}
0