QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661884#4385. Randomsyss#AC ✓11ms3668kbC++20450b2024-10-20 18:45:132024-10-20 18:45:13

Judging History

你现在查看的是最新测评结果

  • [2024-10-20 18:45:13]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3668kb
  • [2024-10-20 18:45:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

constexpr int MOD = 1000000007;

void solve() {
    int n, m;
    cin >> n >> m;

    n -= m;
    if (n % 2 == 0) {
        cout << n / 2 << '\n';
    } else {
        cout << 1LL * n * (MOD + 1) / 2 % MOD << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 11ms
memory: 3668kb

input:

100000
42 30
6335 1161
19170 15725
11479 6401
26963 24465
5706 5322
23282 16828
9962 492
2996 2955
4828 609
32392 14605
3903 154
293 77
17422 1295
19719 177
5448 5383
14772 11539
1870 1213
25668 632
17036 9895
28704 23812
31323 30334
17674 4665
15142 7712
28254 6869
25548 2097
32663 95
20038 12860
8...

output:

6
2587
500001726
2539
1249
192
3227
4735
500000024
500002113
500008897
500001878
108
500008067
9771
500000036
500001620
500000332
12518
500003574
2446
500000498
500006508
3715
500010696
500011729
16284
3589
3853
500013379
500004644
10174
119
49
500007944
500001824
500004584
4510
500006963
500010426
...

result:

ok 100000 lines