結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineqconvexineq
提出日時 2021-01-23 16:05:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 76,748 KB
最終ジャッジ日時 2023-08-29 21:56:08
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,556 KB
testcase_01 AC 67 ms
71,156 KB
testcase_02 AC 70 ms
71,212 KB
testcase_03 AC 68 ms
70,836 KB
testcase_04 AC 69 ms
71,028 KB
testcase_05 AC 70 ms
71,216 KB
testcase_06 AC 90 ms
76,152 KB
testcase_07 AC 87 ms
75,728 KB
testcase_08 AC 94 ms
76,340 KB
testcase_09 AC 94 ms
75,792 KB
testcase_10 AC 93 ms
75,840 KB
testcase_11 AC 528 ms
76,168 KB
testcase_12 AC 576 ms
76,304 KB
testcase_13 AC 667 ms
76,748 KB
testcase_14 AC 478 ms
76,600 KB
testcase_15 AC 502 ms
76,516 KB
testcase_16 AC 415 ms
76,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(x,y):
    if y==0: return 1,0
    r0,r1,s0,s1 = x,y,1,0
    while r1 != 0:
        r0,r1,s0,s1 = r1,r0%r1,s1,s0-r0//r1*s1
    return r0,s0,(r0-s0*x)//y

T = int(input())
for _ in range(T):
    *abc,n = map(int,input().split())
    a,b,c = sorted(abc)
    g,p,q = extgcd(a,b)
    print(sum(t*q//a + t*p//b + 1 for t in range(n,-1,-c) if t%g==0)%1000000007)
0