QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17723 | #874. Long Grid Covering | qingaodong | AC ✓ | 3ms | 3692kb | C++17 | 1.1kb | 2022-01-10 09:47:31 | 2022-05-04 15:40:58 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
constexpr int P = 1000000007;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
i64 n;
std::cin >> n;
int a[6] = {1, 0, 0, P - 1}, b[7] = {1, P - 1, P - 2, P - 6, P - 1, 0, 1};
while (n > 0) {
int c[12] = {}, d[13] = {};
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
c[i + j] = (c[i + j] + i64(a[i]) * (j % 2 == 0 ? b[j] : P - b[j])) % P;
}
}
for (int i = 0; i < 6; i++) {
a[i] = c[2 * i + n % 2];
}
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
d[i + j] = (d[i + j] + i64(b[i]) * (j % 2 == 0 ? b[j] : P - b[j])) % P;
}
}
for (int i = 0; i < 7; i++) {
b[i] = d[2 * i];
}
n /= 2;
}
std::cout << a[0] << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
4 1 2 3 10
output:
1 3 10 8266
result:
ok 4 number(s): "1 3 10 8266"
Test #2:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
100 591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 658 507 620 984 2...
output:
398162564 3923746 347206084 937652677 511984221 356815867 634269583 10 492672877 107350060 647965529 633393631 911425824 746373395 426043114 551287175 772111460 994877654 877599230 88346652 250024200 154039310 461178023 487763582 763918729 537233428 570954868 210301204 911464697 237056565 669291182 ...
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
100 955967370573984956 113166936398978672 934415284373637608 774686535590919223 668528836699949629 65629257521619533 811940940990692618 915621972787306932 228144645291423602 690041707309747302 191003462832708740 981404451712468361 900400340973685384 507894895830950112 730342794302458267 292630995901...
output:
544144276 818067446 86599466 313726969 18938569 632700031 797497759 781547720 391588017 878181169 310434443 416689342 69020235 460227545 162825045 321960509 604698726 745824316 617383608 26101176 816251396 489328969 613075753 821553025 821486393 270559043 786443427 729545800 129844182 893901263 9674...
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 3620kb
input:
100 1000000000000000000 999999999999999999 999999999999999998 999999999999999997 999999999999999996 999999999999999995 999999999999999994 999999999999999993 999999999999999992 999999999999999991 999999999999999990 999999999999999989 999999999999999988 999999999999999987 999999999999999986 9999999999...
output:
776755633 305596516 433884536 271324944 255217955 752347893 279777560 954593517 141741201 121847646 925987319 408911539 615371540 395678394 900921829 709870350 988659472 113218064 830032042 970158982 295607870 455576442 901184396 886355576 365985700 530063682 646456471 944296960 543981115 362793239 ...
result:
ok 100 numbers