QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#447328#5756. NumbersSunnyzbh50 ✓1ms3912kbC++141.1kb2024-06-18 09:55:162024-06-18 09:55:17

Judging History

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

  • [2024-06-18 09:55:17]
  • 评测
  • 测评结果:50
  • 用时:1ms
  • 内存:3912kb
  • [2024-06-18 09:55:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int M=1e4;
struct mat
{
    int a[2][2];
    mat friend operator*(const mat &u,const mat &v)
    {
        mat C;memset(C.a,0,sizeof(C.a));
        for(int k=0;k<2;k++)
        {
            for(int i=0;i<2;i++)
            {
                for(int j=0;j<2;j++)
                {
                    (C.a[i][j]+=u.a[i][k]*v.a[k][j])%=M;
                }
            }
        }
        return C;
  } 
};
mat pow(mat a,ll n)
{
    mat b;b.a[0][0]=b.a[1][1]=1;
    b.a[0][1]=b.a[1][0]=0;
    while(n)
    {
        if(n&1) b=b*a;
        a=a*a;
        n>>=1;
    }
    return b;
}
int n;
const int P=1e3;
void solve()
{
    scanf("%d",&n);
    mat a;
    a.a[0][0]=a.a[1][1]=3;
    a.a[1][0]=1;a.a[0][1]=5;
    a=pow(a,n);
    printf("%03d\n",(a.a[0][0]*2+P-1)%P);
}
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    int tc;scanf("%d",&tc);
    for(int tt=1;tt<=tc;tt++)
    {
        printf("Case #%d: ",tt);
        solve();
    }
    return 0;
}

詳細信息

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 0ms
memory: 3912kb

input:

29
8
24
16
21
15
10
28
9
17
5
23
29
4
25
30
7
19
18
2
11
3
13
26
12
27
20
22
14
6

output:

Case #1: 991
Case #2: 351
Case #3: 991
Case #4: 855
Case #5: 463
Case #6: 047
Case #7: 791
Case #8: 335
Case #9: 095
Case #10: 935
Case #11: 743
Case #12: 135
Case #13: 751
Case #14: 135
Case #15: 647
Case #16: 903
Case #17: 263
Case #18: 607
Case #19: 027
Case #20: 943
Case #21: 143
Case #22: 055
C...

result:

ok 29 lines

Subtask #2:

score: 35
Accepted

Test #2:

score: 35
Accepted
time: 1ms
memory: 3840kb

input:

100
1999999991
1009443858
1471682254
1422967024
1637426906
1769891921
1193286625
1065739040
1467138669
652388696
1153366704
1999999994
1999999999
1564410450
838575637
774478813
1021866159
1692422732
1403894323
2000000000
1684867696
311294123
1535083560
1366514967
1394642925
498451717
1404554424
6910...

output:

Case #1: 543
Case #2: 007
Case #3: 247
Case #4: 351
Case #5: 607
Case #6: 855
Case #7: 135
Case #8: 551
Case #9: 735
Case #10: 791
Case #11: 751
Case #12: 047
Case #13: 063
Case #14: 247
Case #15: 095
Case #16: 055
Case #17: 663
Case #18: 471
Case #19: 743
Case #20: 751
Case #21: 791
Case #22: 743
C...

result:

ok 100 lines

Extra Test:

score: 0
Extra Test Passed