QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745508#7990. 广播ucup-team4352#WA 212ms114480kbC++231.3kb2024-11-14 10:24:042024-11-14 10:24:04

Judging History

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

  • [2024-11-14 10:24:04]
  • 评测
  • 测评结果:WA
  • 用时:212ms
  • 内存:114480kb
  • [2024-11-14 10:24:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=1000+5;
const int mod=1e9+7;
int T,k,m,n;
char s[maxn];
inline bool solve(int x) {
	int js=1;
	while(js<k&&js<4) {
		js++;
		int res=0;
		while(x) {
			res+=x%10;
			x/=10;
		}
		x=res;
	}
	return x==m;
}
inline void add(int &x,int y) {
	x+=y;
	if(x>=mod) x-=mod;
}
int sol[maxn][9005];
void Init() {
	int N=1000;
	sol[0][0]=1;
	for(int i=1;i<=N;++i) {
		for(int j=0;j<=(i-1)*9;++j) {
			if(sol[i-1][j]==0) continue;
			for(int u=0;u<=9;++u) {
				add(sol[i][j+u],sol[i-1][j]);
			}
		}
	}
}
int dp[maxn][2][9005];
bool vis[maxn][2][9005];
int dfs(int p,int flag,int sum) {
	if(flag==0) return sol[n-p][sum];
	if(vis[p][flag][sum]) return dp[p][flag][sum];
	if(p==n) {
		if(sum==0) return 1;
		return 0;
	}
	vis[p][flag][sum]=1;
	int Max=9;
	if(flag) Max=(s[p+1]-'0');
	Max=min(Max,sum);
	int res=0;
	for(int i=0;i<=Max;++i) {
		add(res,dfs(p+1,flag&&(i==Max),sum-i));
	}
	return dp[p][flag][sum]=res;
}
int main() {
	T=5;
	//scanf("%d",&T);
	Init();
	while(T--) {
		n=1000;
		for(int i=1;i<=1000;++i) s[i]='9';
		m=1,k=6;
		//scanf("%s%d%d",s+1,&k,&m),n=strlen(s+1);
		int ans=0;
		for(int j=0;j<=n*9;++j) if(solve(j)) add(ans,dfs(0,1,j));
		printf("%d\n",ans);
		memset(vis,0,sizeof(vis));
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 212ms
memory: 114480kb

input:

4 2
2 1 3 2
4 2

output:

357970005
357970005
357970005
357970005
357970005

result:

wrong answer 1st lines differ - expected: '1', found: '357970005'