結果

問題 No.639 An Ordinary Sequence
ユーザー kwnwsdnckwnwsdnc
提出日時 2018-02-23 00:23:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-08-30 12:54:42
合計ジャッジ時間 1,237 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,732 KB
testcase_01 AC 19 ms
7,816 KB
testcase_02 AC 17 ms
7,896 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 15 ms
7,784 KB
testcase_05 AC 14 ms
7,732 KB
testcase_06 AC 15 ms
7,872 KB
testcase_07 AC 15 ms
7,852 KB
testcase_08 AC 14 ms
7,788 KB
testcase_09 AC 14 ms
7,860 KB
testcase_10 AC 14 ms
7,748 KB
testcase_11 AC 14 ms
7,844 KB
testcase_12 AC 16 ms
7,784 KB
testcase_13 AC 16 ms
7,804 KB
testcase_14 AC 16 ms
7,756 KB
testcase_15 AC 16 ms
7,800 KB
testcase_16 AC 16 ms
7,876 KB
testcase_17 AC 15 ms
7,752 KB
testcase_18 AC 17 ms
7,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sequence(n):
    if n==0:
        return 1
    else:
        return sequence(int(n/3))+sequence(int(n/5))
    
def com(a,b):
    N=1
    i=b
    
    if a==b or b==0:
        return 1
    else:
        while i>=1:
            N*=a
            a-=1
            i-=1
        while b>=1:
            N/=b
            b-=1
        return N
    

N=int(input())
i=0
j=0
M=N
total=0
while M>1:
    M=M/5
    i+=1

while j<=i:
    total+=com(i,j)*sequence(int(M*((5/3)**j)))
    j+=1
    



print('%d'%total)
0