結果
問題 | No.1252 数字根D |
ユーザー |
👑 ![]() |
提出日時 | 2020-08-25 01:19:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 245 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 72,576 KB |
最終ジャッジ日時 | 2024-11-07 14:21:15 |
合計ジャッジ時間 | 1,984 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
def g(N):if N==0:return 0if N%(D-1)==0:Q=N//(D-1)R=0else:Q=N//(D-1)+1R=D-1-N%(D-1)return Q*(D*(D-1))//2-D*R+(R*(R+1))//2T=int(input())assert 1<=T<=2000,"Tが範囲外(T={})".format(T)X=[0]*Tfor k in range(T):D,A,B=map(int,input().split())assert 2<=D<=10**9,"(第{}テストケース)Dが範囲外(D={})".format(k+1,D)assert 0<=A<=B<=10**9,"(第{}テストケース)A,Bが範囲外(A={},B={})".format(k+1,A,B)X[k]=g(B)-g(max(A-1,0))print("\n".join(map(str,X)))