QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#613032 | #9435. Welcome to NPCAPC | ucup-team918# | WA | 1ms | 4684kb | C++14 | 1.2kb | 2024-10-05 13:27:42 | 2024-10-05 13:27:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int Mod=998244353;
struct Matrix
{
long long a[50][50];
Matrix()
{
memset(a,0,sizeof(a));
}
Matrix operator *(const Matrix& oth) const
{
Matrix res;
for(int i=0;i<=6;i++)
for(int j=0;j<=6;j++)
{
int S=i*7+j;
for(int k=i;k<=6;k++)
for(int p=j;p<=6;p++)
{
int T=k*7+p;
if(a[S][T])
{
for(int x=k;x<=6;x++)
for(int y=p;y<=6;y++)
{
int r=x*7+y;
(res.a[S][r] += a[S][T]*oth.a[T][r]) %= Mod;
}
}
}
}
return res;
}
} trans[35];
map <int,int> ans;
void work()
{
int n;
scanf("%d",&n);
if(ans.count(n))
printf("%d\n",ans[n]);
Matrix start;
start.a[0][0]=1;
for(int i=0;i<=30;i++)
if((n>>i)&1)
start=start*trans[i];
ans[n]=start.a[0][48];
printf("%d\n",ans[n]);
}
int main()
{
for(int i=0;i<=6;i++)
for(int j=0;j<=6;j++)
{
int sum=52;
if(i!=6)
trans[0].a[i*7+j][(i+1)*7+j]++, sum--;
if(j!=6)
trans[0].a[i*7+j][i*7+j+1]++, sum--;
trans[0].a[i*7+j][i*7+j]=sum;
}
for(int i=1;i<=30;i++)
trans[i]=trans[i-1]*trans[i-1];
int T;
cin >> T;
while(T--)
work();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4620kb
input:
4 12 6 5839 123456
output:
924 0 966252995 432934749
result:
ok 4 number(s): "924 0 966252995 432934749"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4604kb
input:
3 123456789 987654321 999999999
output:
333574957 124462731 163251704
result:
ok 3 number(s): "333574957 124462731 163251704"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4600kb
input:
10 19425 102461 155567 158836 113140 53389 161281 4594 30575 108615
output:
373186365 206571483 970383134 989350567 625537601 996030441 764136313 478343127 585610797 77642861
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 4612kb
input:
10 194023 129263 48544 122512 184189 36584 109090 185910 157471 165449
output:
646584725 685247409 562517647 135100440 554171085 18276445 599247609 645458744 157353305 961701460
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 4604kb
input:
10 62619 102803 103157 53078 141131 131278 107572 72144 3962 2993
output:
336681005 218835081 977425093 939622730 599861248 730434007 143005189 81452469 648743259 392146337
result:
ok 10 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 4496kb
input:
10 115339 14918 142121 161511 64217 158940 60253 133675 8663 16414
output:
447424283 701409014 925899837 229615050 384906046 868361271 510779619 719867379 676960448 767190917
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
10 85495 199819 142473 79698 166538 169504 10264 127098 60974 49524
output:
758217665 362989371 849601874 914823277 258052558 895462991 815236067 354182017 319596227 827075400
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 4604kb
input:
10 1425 152469 89993 198158 35858 99757 121657 13600 1674 146517
output:
696406093 386918828 204106049 632497695 611949542 844728055 614167688 322636556 426859719 892745895
result:
ok 10 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 4540kb
input:
10 54362 116337 187366 29763 59353 2441 42427 123694 39351 17442
output:
770174476 485360795 966181928 673166447 778039253 223255284 308023018 467109595 776512421 478342322
result:
ok 10 numbers
Test #10:
score: 0
Accepted
time: 1ms
memory: 4496kb
input:
10 164862 189993 197025 186958 183986 19454 195717 3595 37637 12900
output:
947618397 310127426 515768872 713650103 443160420 174103041 140536245 261888957 199480824 62935695
result:
ok 10 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 4684kb
input:
10 28188 195373 19757 86671 172167 174607 177795 177036 12036 112202
output:
503461377 349476278 864992772 433340965 139666723 854367908 243493730 1094272 259503082 826525753
result:
ok 10 numbers
Test #12:
score: 0
Accepted
time: 1ms
memory: 4500kb
input:
10 88207 181591 178531 140277 166887 34746 6840 165413 59380 59478
output:
143757409 281674172 448638880 297367509 478750591 255032414 933878821 32023173 935444021 274623740
result:
ok 10 numbers
Test #13:
score: -100
Wrong Answer
time: 1ms
memory: 4628kb
input:
10 200000 200000 200000 200000 200000 200000 200000 200000 200000 200000
output:
506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892 506140892
result:
wrong answer Output contains longer sequence [length = 19], but answer contains 10 elements