結果

問題 No.1252 数字根D
ユーザー taiga000629taiga000629
提出日時 2020-10-10 00:02:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 77,864 KB
最終ジャッジ日時 2023-09-27 20:18:14
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,060 KB
testcase_01 AC 63 ms
71,284 KB
testcase_02 AC 65 ms
71,148 KB
testcase_03 AC 82 ms
75,968 KB
testcase_04 AC 114 ms
77,808 KB
testcase_05 AC 99 ms
77,648 KB
testcase_06 AC 97 ms
77,604 KB
testcase_07 AC 96 ms
77,728 KB
testcase_08 AC 95 ms
77,540 KB
testcase_09 AC 97 ms
77,764 KB
testcase_10 AC 98 ms
77,484 KB
testcase_11 AC 96 ms
77,864 KB
testcase_12 AC 95 ms
77,556 KB
testcase_13 AC 96 ms
77,556 KB
testcase_14 AC 63 ms
71,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
ans=[]
for i in range(t):
    d,a,b=map(int,input().split())
    p=d-1
    if a==0:
        if b==0:
            ans.append(0)
            continue
        else:
            a=1
    T=p*(p+1)//2
    k=(a-1)//p
    l=(a-1)%p+1
    y=(b-1)//p
    z=(b-1)%p+1

    if k<y:
        res=T*(y-k-1)
        res+=(p-l+1)*(p+l)//2
        res+=z*(z+1)//2
        ans.append(res)
    else:
        res=0
        res+=(z-l+1)*(z+l)//2
        ans.append(res)
for i in range(t):
    print(ans[i])
0