ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199867 | #177. move | Anonyme | 100 | 1104ms | 16872kb | C++11 | 1005b | 2023-12-24 09:03:54 | 2023-12-24 12:14:11 |
answer
#include<bits/stdc++.h>
using namespace std;
#define QwQ330AwA return 0
#define ll long long
const int N = 1e6 + 6;
const int mod = 1e9 + 7;
ll fac[N], inv[N];
ll C(int n, int m) {
if (n < m) return 0;
return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
ll ksm(ll a, int b) {
ll ans = 1;
for (; b; b >>= 1, a = a * a % mod) {
if (b & 1) ans = ans * a % mod;
}
return ans;
}
void solve() {
int n;
cin >> n;
ll ans = 0;
for (int i = 0; i < n; i++) {
int m = n - i;
if (m & 1) continue;
m /= 2;
ans = (ans + C(n, i) * ((C(2 * m, m) - C(2 * m, m - 1) % mod + mod) % mod) % mod) % mod;
}
ans = (ans + 1) % mod;
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
fac[0] = 1;
for (int i = 1; i <= 1000000; i++) fac[i] = fac[i - 1] * i % mod;
inv[1000000] = ksm(fac[1000000], mod - 2) % mod;
for (int i = 1000000; i >= 1; i--) inv[i - 1] = inv[i] * i % mod;
int t;
cin >> t;
while (t--) solve();
QwQ330AwA;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 9ms
memory: 16868kb
input:
10 87 126 336 401 396 393 990 967 308 130
output:
952886086 778103891 301307310 497097012 267466056 695715027 490133361 19295392 313508734 87611670
result:
ok 10 lines
Test #2:
score: 5
Accepted
time: 9ms
memory: 16868kb
input:
10 776 458 70 270 555 836 935 748 272 375
output:
692921871 445495094 774348257 379818824 888898709 174497833 196545526 118997364 299113390 299856448
result:
ok 10 lines
Test #3:
score: 5
Accepted
time: 13ms
memory: 16872kb
input:
10 855 340 58 805 522 354 251 543 823 269
output:
615565992 819883319 298217690 69689203 884819632 264378106 122305893 483673609 538195482 765591101
result:
ok 10 lines
Test #4:
score: 5
Accepted
time: 0ms
memory: 16872kb
input:
10 861 814 845 431 88 290 723 925 653 987
output:
66379951 218730106 646412481 779603910 934817196 549036495 938207208 515670413 187358499 885002046
result:
ok 10 lines
Test #5:
score: 5
Accepted
time: 18ms
memory: 16872kb
input:
10 5139 6360 6177 3920 1126 9257 5310 927 1028 723
output:
53992314 779209990 272656703 726194903 575528693 99668723 175131710 16492713 58158406 938207208
result:
ok 10 lines
Test #6:
score: 5
Accepted
time: 16ms
memory: 16868kb
input:
10 421 6323 1406 4271 9545 241 9785 6155 8416 8625
output:
504938765 241955822 418503361 879313548 600795516 401159863 845118197 688275255 813359771 170747506
result:
ok 10 lines
Test #7:
score: 5
Accepted
time: 19ms
memory: 16868kb
input:
10 1623 7654 2419 5220 7788 6086 4514 878 8719 889
output:
985056431 366520371 610623700 79873919 152612466 564409096 826125318 108992217 884889426 299052566
result:
ok 10 lines
Test #8:
score: 5
Accepted
time: 14ms
memory: 16868kb
input:
10 4834 9049 5788 5053 2368 678 7019 8699 6095 9771
output:
894248955 48762405 157733240 975780451 870697369 618636072 8225406 846511000 723654845 466048177
result:
ok 10 lines
Test #9:
score: 5
Accepted
time: 11ms
memory: 16868kb
input:
10 9992 9411 7282 2934 2901 2668 6567 4524 4102 8524
output:
75603159 139639091 827313831 749841764 833868754 310259549 804778809 416380457 20118359 546399661
result:
ok 10 lines
Test #10:
score: 5
Accepted
time: 4ms
memory: 16872kb
input:
10 9520 2862 3208 7053 9602 2486 9472 8500 3375 6827
output:
168898108 549139767 780176643 823630021 91024868 918528824 298818369 236242005 173037285 224016415
result:
ok 10 lines
Test #11:
score: 5
Accepted
time: 114ms
memory: 16872kb
input:
10 59737 856616 467799 850140 940542 645886 381456 829699 317966 558490
output:
839529689 148943889 832435699 656537703 309790708 896597601 884248120 847282933 610220680 17852453
result:
ok 10 lines
Test #12:
score: 5
Accepted
time: 65ms
memory: 16872kb
input:
10 836166 344091 589267 224275 743829 124824 37191 619801 314432 25360
output:
363572876 802728099 713874676 652189567 833071556 653110228 600371759 443480105 341963835 459920462
result:
ok 10 lines
Test #13:
score: 5
Accepted
time: 52ms
memory: 16872kb
input:
10 619868 45579 115131 121441 523910 321297 324365 602432 805322 490275
output:
528209934 480081255 386752639 15197841 617475320 8989877 616139785 763612257 554465540 480653058
result:
ok 10 lines
Test #14:
score: 5
Accepted
time: 94ms
memory: 16868kb
input:
10 552883 123886 867678 885767 850366 997032 984348 337236 233611 175426
output:
910799573 555873268 275513814 647312715 798769572 133859592 837931577 653969046 453890146 433794677
result:
ok 10 lines
Test #15:
score: 5
Accepted
time: 74ms
memory: 16872kb
input:
10 395505 432537 433480 262843 655874 343802 741245 868350 317808 682914
output:
781690159 128762586 44286220 902962745 242841990 280305487 885695030 246608547 143918021 262112863
result:
ok 10 lines
Test #16:
score: 5
Accepted
time: 121ms
memory: 16868kb
input:
10 63349 886119 176835 613938 308562 578253 594380 699798 689504 617810
output:
583981305 176628003 564919936 576538515 775560152 143079589 563319325 834895660 585267643 507384150
result:
ok 10 lines
Test #17:
score: 5
Accepted
time: 123ms
memory: 16868kb
input:
10 346593 166648 733852 27658 749332 551494 306467 928849 204793 778283
output:
772457634 24388769 933904578 513219933 329059863 109045106 455847970 560314790 989158553 189795809
result:
ok 10 lines
Test #18:
score: 5
Accepted
time: 135ms
memory: 16872kb
input:
10 756444 771536 854707 86019 86784 666644 755548 534218 82420 950867
output:
371708117 254410932 897168639 296496017 532423155 174791785 399453127 566608229 764210643 276037323
result:
ok 10 lines
Test #19:
score: 5
Accepted
time: 118ms
memory: 16872kb
input:
10 803327 236316 216530 558863 957651 635525 773678 28658 600968 485504
output:
783030543 907156811 592914588 488077290 398405119 265899907 552853838 178755889 861447556 422291694
result:
ok 10 lines
Test #20:
score: 5
Accepted
time: 95ms
memory: 16868kb
input:
10 836166 344091 589267 224275 743829 124824 37191 619801 314432 25360
output:
363572876 802728099 713874676 652189567 833071556 653110228 600371759 443480105 341963835 459920462
result:
ok 10 lines