結果
問題 | No.1803 Remainder of Sum |
ユーザー |
![]() |
提出日時 | 2022-01-07 22:15:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 221 ms / 2,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 1,559 ms |
コンパイル使用メモリ | 167,640 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 08:49:37 |
合計ジャッジ時間 | 4,385 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long ap_sum(long long a, long long b){ return (b + a) * (b - a + 1) / 2; } int main(){ int T; cin >> T; for (int i = 0; i < T; i++){ int N, M; cin >> N >> M; if (N < M){ if (M % 2 == 0){ long long ans = N - M / 2; ans += ap_sum(3, M - N + 1); cout << ans << endl; } else { long long ans = N - M / 2 - 1; ans += ap_sum(3, M - N + 1); cout << ans << endl; } } else { cout << M / 2 << endl; } } }