結果

問題 No.1252 数字根D
ユーザー anagohirameanagohirame
提出日時 2020-10-09 22:41:15
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 76,496 KB
最終ジャッジ日時 2023-09-27 18:37:07
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
70,988 KB
testcase_01 AC 64 ms
70,920 KB
testcase_02 AC 61 ms
70,916 KB
testcase_03 AC 74 ms
75,424 KB
testcase_04 AC 87 ms
76,204 KB
testcase_05 AC 83 ms
76,316 KB
testcase_06 AC 83 ms
76,240 KB
testcase_07 AC 82 ms
76,372 KB
testcase_08 AC 81 ms
76,240 KB
testcase_09 AC 83 ms
76,496 KB
testcase_10 AC 84 ms
76,384 KB
testcase_11 AC 85 ms
76,336 KB
testcase_12 AC 84 ms
76,400 KB
testcase_13 AC 87 ms
76,376 KB
testcase_14 AC 63 ms
71,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

def f(d, x):
	if x <= 0:
		return 0
	else:
		res = 0
		res += (d * (d-1) // 2) * ((x-1) // (d-1))
		res += ((x-1) % (d-1) + 1) * ((x-1) % (d-1) + 2) // 2
		return res

for _ in range(int(input())):
	d, a, b = map(int, input().split())
	print(f(d, b) - f(d, a-1))
0