提出 #20094865
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
// a + (a+1) + ... + b
long sum(const long &a, const long &b) { return (a + b) * (b - a + 1) / 2; }
int main() {
int T;
cin >> T;
while (T--) {
long L, R;
cin >> L >> R;
const long minC = L;
const long maxC = R - L;
if (minC > maxC) {
cout << 0 << endl;
} else {
cout << sum(R - maxC - L + 1, R - minC - L + 1) << endl;
}
}
return 0;
}
提出情報
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample.txt |
| All | 00maxA.txt, 00maxB.txt, prefix.txt, random.txt, random_2.txt, random_3.txt, random_4.txt, sample.txt, small.txt, small_2.txt, suffix.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00maxA.txt | AC | 52 ms | 3572 KiB |
| 00maxB.txt | AC | 49 ms | 3448 KiB |
| prefix.txt | AC | 48 ms | 3632 KiB |
| random.txt | AC | 46 ms | 3452 KiB |
| random_2.txt | AC | 51 ms | 3604 KiB |
| random_3.txt | AC | 50 ms | 3532 KiB |
| random_4.txt | AC | 47 ms | 3452 KiB |
| sample.txt | AC | 3 ms | 3528 KiB |
| small.txt | AC | 44 ms | 3440 KiB |
| small_2.txt | AC | 7 ms | 3416 KiB |
| suffix.txt | AC | 49 ms | 3460 KiB |