結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー aaaaaaaaaa2230
提出日時 2024-02-23 22:20:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,421 ms / 2,000 ms
コード長 218 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 13,456 KB
最終ジャッジ日時 2024-09-29 07:11:08
合計ジャッジ時間 15,648 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.set_int_max_str_digits(0)

t = int(input())

def nC2(n):
	return n*(n+1)//2
for _ in range(t):
	n,m = map(int,input().split())
	p = n//m
	d = n%m
	
	p %= m

	ans = (nC2(m-1) * p + nC2(d))%m
	
	print(ans)
0