結果

問題 No.1312 Snake Eyes
ユーザー buey_tbuey_t
提出日時 2023-03-23 11:22:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,700 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 88,804 KB
最終ジャッジ日時 2023-10-18 19:28:13
合計ジャッジ時間 16,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
84,404 KB
testcase_01 AC 137 ms
84,224 KB
testcase_02 AC 135 ms
84,408 KB
testcase_03 AC 135 ms
84,408 KB
testcase_04 AC 133 ms
84,412 KB
testcase_05 AC 134 ms
84,224 KB
testcase_06 AC 134 ms
84,408 KB
testcase_07 AC 133 ms
84,412 KB
testcase_08 AC 133 ms
84,408 KB
testcase_09 AC 133 ms
84,412 KB
testcase_10 AC 131 ms
84,412 KB
testcase_11 AC 133 ms
84,408 KB
testcase_12 AC 132 ms
84,408 KB
testcase_13 AC 135 ms
84,408 KB
testcase_14 AC 134 ms
84,408 KB
testcase_15 AC 132 ms
84,408 KB
testcase_16 AC 134 ms
84,408 KB
testcase_17 AC 131 ms
84,408 KB
testcase_18 AC 131 ms
84,188 KB
testcase_19 AC 131 ms
84,180 KB
testcase_20 AC 131 ms
84,408 KB
testcase_21 AC 132 ms
84,220 KB
testcase_22 AC 145 ms
88,776 KB
testcase_23 AC 145 ms
88,760 KB
testcase_24 AC 146 ms
88,772 KB
testcase_25 AC 146 ms
88,772 KB
testcase_26 AC 145 ms
88,772 KB
testcase_27 AC 150 ms
88,772 KB
testcase_28 AC 133 ms
84,408 KB
testcase_29 AC 147 ms
88,764 KB
testcase_30 AC 146 ms
88,748 KB
testcase_31 AC 144 ms
88,772 KB
testcase_32 AC 145 ms
88,772 KB
testcase_33 AC 154 ms
88,772 KB
testcase_34 AC 146 ms
88,776 KB
testcase_35 AC 151 ms
88,776 KB
testcase_36 AC 147 ms
88,768 KB
testcase_37 AC 148 ms
88,772 KB
testcase_38 AC 147 ms
88,772 KB
testcase_39 AC 177 ms
88,788 KB
testcase_40 AC 156 ms
88,776 KB
testcase_41 AC 176 ms
88,780 KB
testcase_42 AC 184 ms
88,788 KB
testcase_43 AC 185 ms
88,780 KB
testcase_44 AC 178 ms
88,788 KB
testcase_45 AC 156 ms
88,780 KB
testcase_46 AC 176 ms
88,792 KB
testcase_47 AC 176 ms
88,780 KB
testcase_48 AC 191 ms
88,772 KB
testcase_49 AC 190 ms
88,792 KB
testcase_50 AC 201 ms
88,784 KB
testcase_51 AC 182 ms
88,804 KB
testcase_52 AC 189 ms
88,776 KB
testcase_53 AC 186 ms
88,792 KB
testcase_54 AC 189 ms
88,784 KB
testcase_55 AC 181 ms
88,780 KB
testcase_56 AC 176 ms
88,776 KB
testcase_57 AC 186 ms
88,784 KB
testcase_58 AC 203 ms
88,784 KB
testcase_59 AC 159 ms
88,776 KB
testcase_60 AC 185 ms
88,788 KB
testcase_61 AC 191 ms
88,792 KB
testcase_62 AC 160 ms
88,768 KB
testcase_63 AC 149 ms
88,768 KB
testcase_64 AC 133 ms
84,176 KB
testcase_65 AC 133 ms
84,408 KB
testcase_66 AC 147 ms
88,764 KB
testcase_67 AC 137 ms
84,220 KB
testcase_68 AC 134 ms
84,408 KB
testcase_69 AC 135 ms
84,408 KB
testcase_70 AC 133 ms
84,404 KB
testcase_71 AC 135 ms
84,408 KB
testcase_72 AC 133 ms
84,408 KB
testcase_73 AC 134 ms
84,404 KB
testcase_74 AC 132 ms
84,408 KB
testcase_75 AC 130 ms
84,408 KB
testcase_76 AC 174 ms
88,776 KB
testcase_77 AC 190 ms
88,792 KB
testcase_78 AC 176 ms
88,776 KB
testcase_79 AC 134 ms
84,404 KB
testcase_80 AC 175 ms
88,780 KB
testcase_81 AC 168 ms
88,780 KB
testcase_82 AC 150 ms
88,772 KB
testcase_83 AC 195 ms
88,768 KB
testcase_84 AC 193 ms
88,772 KB
testcase_85 AC 134 ms
84,408 KB
testcase_86 AC 133 ms
84,412 KB
testcase_87 AC 183 ms
88,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    
    
    
    '''
    
    def Dec_to_N(num, base):
        if num >= base:
            yield from Dec_to_N(num // base, base)
        yield num % base

    def N_to_Dec(digits, base):
        num = 0
        for digit in digits:
            num = num * base + digit
        return num

    
    N = int(input())
    
    for i in range(2,10**6+1):
        tmp = 0
        while tmp*i+1 <= N:
            tmp *= i
            tmp += 1
        
        if N%tmp == 0 and 1<=N//tmp<i:
            print(i)
            exit()
    
    ans = INF
    for i in range(1,int(sqrt(N))+1):
        if N%i == 0:
            j = N//i
            
            p = j-1
            
            if 1<=i<p:
                ans = min(ans, p)
    
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0