QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135476#6637. Perfect StringsPlentyOfPenaltyRE 21ms3688kbC++14621b2023-08-05 16:01:492023-08-05 16:01:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-05 16:01:50]
  • 评测
  • 测评结果:RE
  • 用时:21ms
  • 内存:3688kb
  • [2023-08-05 16:01:49]
  • 提交

answer

#include "bits/stdc++.h"
typedef std::pair<int,int> pii;
typedef long long ll;
const int MAXN = 111,mod = 1e9+7;
int f[MAXN][MAXN];
int main()
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    int task;std::cin>>task;
    while(task--)
    {
        int n,c;std::cin>>n>>c;
        f[0][0]=1;
        for(int i=1;i<=n*2;++i)
            for(int j=0;j<=n;++j)
            {
                f[i][j]=0;
                if(j>=1)f[i][j]=ll(f[i-1][j-1])*(j==1?c:c-1)%mod;
                f[i][j]=(f[i][j]+f[i-1][j+1])%mod;
            }
        printf("%d\n",f[n*2][0]);
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3688kb

input:

2
3 1
2 2

output:

1
6

result:

ok 2 number(s): "1 6"

Test #2:

score: 0
Accepted
time: 21ms
memory: 3668kb

input:

100000
1 1
4 1
5 5
3 5
1 2
5 3
1 1
3 3
5 2
2 1
4 1
5 5
2 3
4 1
3 3
2 5
3 2
4 3
4 4
3 5
3 1
5 2
2 2
4 2
5 4
1 2
3 1
4 5
2 5
5 3
1 5
5 2
3 2
5 2
4 1
1 3
3 2
4 5
2 1
4 1
2 2
1 1
3 5
4 5
2 3
3 5
2 5
2 4
5 4
2 3
1 1
2 1
4 4
1 5
5 4
1 3
5 4
4 5
1 3
1 1
3 3
2 4
2 4
2 1
5 5
1 3
2 3
4 1
4 3
2 4
2 4
4 2
1 1
1...

output:

1
1
71445
485
2
3543
1
87
252
1
1
71445
15
1
87
45
20
543
2092
485
1
252
6
70
19864
2
1
5725
45
3543
5
252
20
252
1
3
20
5725
1
1
6
1
485
5725
15
485
45
28
19864
15
1
1
2092
5
19864
3
19864
5725
3
1
87
28
28
1
71445
3
15
1
543
28
28
70
1
1
71445
15
2092
3
1
2
15
87
2092
19864
71445
6
252
2092
252
15...

result:

ok 100000 numbers

Test #3:

score: -100
Runtime Error

input:

100000
94 7867320
84 1294950
35 8570570
72 7050952
23 3907221
95 7482398
58 2363048
44 2234552
50 8809524
37 1061961
19 884367
38 3261675
59 1563189
61 7603994
83 3131714
19 6207284
64 5662457
2 6845951
84 4688192
13 7552675
38 3119650
84 6311084
10 5040332
53 5981961
46 7308176
43 679952
30 2922213...

output:


result: