結果

問題 No.1252 数字根D
ユーザー kozykozy
提出日時 2020-10-09 21:38:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-09-27 15:41:35
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,772 KB
testcase_01 AC 14 ms
7,852 KB
testcase_02 AC 14 ms
7,812 KB
testcase_03 AC 22 ms
7,768 KB
testcase_04 AC 29 ms
7,848 KB
testcase_05 AC 30 ms
7,936 KB
testcase_06 AC 29 ms
7,940 KB
testcase_07 AC 28 ms
7,852 KB
testcase_08 AC 29 ms
7,920 KB
testcase_09 AC 28 ms
7,852 KB
testcase_10 AC 28 ms
7,920 KB
testcase_11 AC 28 ms
7,904 KB
testcase_12 AC 28 ms
7,816 KB
testcase_13 AC 29 ms
7,912 KB
testcase_14 AC 15 ms
7,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def suti(S):
    if S%d==0:
        return d
    else:
        return S%d
Q=int(input())
for i in range(Q):
    d,a,b=map(int,input().split())
    if a==0:
      if b==0:
        print(0)
        continue
      else:
        a=1
    d-=1
    s=(b-a)//d
    ans=(((1+d)*d)//2)*s
    a=suti(a)
    b=suti(b)
    if a<b:
        ans+=((b-a+1)*(b+a))//2
        print(ans)
    elif a==b:
        print(ans+a)
    else:
        ans+=((d-a+1)*(d+a))//2
        ans+=((b)*(b+1))//2
        print(ans)
0