結果

問題 No.639 An Ordinary Sequence
ユーザー kwnwsdnc
提出日時 2018-02-23 00:23:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2025-01-02 02:19:59
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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