Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
6554 | 18级张钰晨 | 2021北京队选拔模拟赛1-C | C++ | 内存超限 | 0 | 166 MS | 170496 KB | 852 | 2021-04-03 15:16:30 |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e3+5,mod=9973,inf=0x3f3f3f3f,tot=3*7*11*47,t[5]={1,2,3,5,7}; inline int read(){ int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();} return x*f; } ll n,a[maxn][tot],tn=1,ans; int main(){ n=read(); a[1][1]=1;a[1][3]=1;a[1][7]=1; for(int i=2;i<=n;i++){ tn=(tn*10)%tot; for(int j=0;j<5;j++) for(int k=0;k<tot;k++) a[i][(k+tn*t[j]%tot)%tot]=(a[i][(k+tn*t[j]%tot)%tot]+a[i-1][k])%mod; } for(int i=1;i<tot;i++)if(i%3&&i%7&&i%11&&i%47)ans=(ans+a[n][i])%mod; // for(int i=1;i<tot;i++){ // if(a[n][i])cout<<i<<" "; // }cout<<endl; printf("%lld\n",ans); return 0; }