ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199975 | #177. move | tkswls | 100 | 4848ms | 16872kb | C++11 | 965b | 2023-12-24 11:45:57 | 2023-12-24 12:20:34 |
answer
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define int long long
using namespace std;
const int mod = 1000000007;
int jie[1000006], inv[1000006], t, n, ans;
inline int ksm(int p, int q = mod - 2) {
int base = 1;
while (q) {
if (q & 1) base = base * p % mod;
q >>= 1;
p = p * p % mod;
}
return base;
}
inline int C(int p, int q) {
if (p < 0 || q < 0 || p < q) return 0;
return jie[p] * inv[q] % mod * inv[p - q] % mod;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
jie[0] = inv[0] = 1;
for (int i = 1; i <= 1000000; i++) {
jie[i] = jie[i - 1] * i % mod;
}
inv[1000000] = ksm(jie[1000000], mod - 2);
for (int i = 1000000 - 1; i >= 0; i--) {
inv[i] = inv[i + 1] * (i + 1) % mod;
}
cin >> t;
while (t--) {
cin >> n;
ans = 0;
for (int i = 0; i * 2 <= n; i++) {
ans += C(n, 2 * i) * C(2 * i, i) % mod * ksm(i + 1) % mod;
ans %= mod;
}
cout << ans << "\n";
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 14ms
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: 12ms
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: 8ms
memory: 16868kb
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: 12ms
memory: 16868kb
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: 10ms
memory: 16868kb
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: 7ms
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: 13ms
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: 26ms
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: 16ms
memory: 16872kb
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: 13ms
memory: 16868kb
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: 575ms
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: 358ms
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: 397ms
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: 593ms
memory: 16872kb
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: 453ms
memory: 16868kb
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: 462ms
memory: 16872kb
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: 431ms
memory: 16872kb
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: 542ms
memory: 16868kb
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: 524ms
memory: 16868kb
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: 382ms
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