QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657902#7996. 报数 IVyuanyq5523#Compile Error//C++202.2kb2024-10-19 15:40:572024-10-19 15:41:01

Judging History

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

  • [2024-10-19 15:41:01]
  • 评测
  • [2024-10-19 15:40:57]
  • 提交

answer

/*
ANALYSIS:

*/
#pragma GCC optimize(3);
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <ctime>
#include <random>
#define int long long
#define endl '\n'
using namespace std;
const int N=1e3+5;
const int mx=1e3;
const int mod=1e9+7;
int A[N][N*10],psum[N];
int n,k,m;
string S;

void cal(){
	A[0][0]=1;
	for (int j=1;j<=mx;j++) A[0][j]=0;
	for (int i=1;i<=mx;i++){
		for (int j=0;j<=mx;j++){
			for (int k=max(j-9,0ll);k<=j;k++){
				A[i][j]=(A[i][j]+A[i-1][k])%mod;
			}
		}
	}
	// cout<<"A"<<endl;
	// for (int i=1;i<=20;i++){
	// 	for (int j=0;j<=20;j++){
	// 		cout<<A[i][j]<<' ';
	// 	}cout<<endl;
	// }
}

int C(int value)
{
	vector<int> ans(n+5,0);
	for (int i=1;i<=n;i++)//后i位
	{
		int x=(int)(S[n-i+1]-'0'),cnt=0;
		for (int j=0;j<=x-1;j++) cnt=(cnt+A[i-1][value-psum[n-i]-j])%mod;
		ans[i]=(cnt+ans[i-1])%mod;
	}
	return ans[n];
}
inline int f(int n)
{
	int res=0;
	while(n>0)
	{
		res+=n%10;
		n/=10;
	}
	return res;
}
void solution()
{
	cin>>S>>k>>m;
	n=S.length();
	S=' '+S;
	psum[0]=0;
	for(int i=1;i<=S.length();i++)
	{
		psum[i]+=S[i]-'0'+psum[i-1];
	}
	int finalans=0;
	for(int i=1;i<=9000;i++)
	{
		int ti=i;
		for(int t=1;t<=k-1;t++)
		{
			if(ti<=9)break;
			ti=f(ti);
		}
		if(ti==m)
		{
			//cout<<i<<' '<<C(i)<<endl;
			finalans+=C(i);
		}
	}
	cout<<endl;
	cout<<finalans<<endl;

	// int cnt=0,psum=0;
	// for(int i=1;i<=n;i++)psum+=S[i]-'0';
	// vector<int> ans(n+5,0);
	// for (int i=1;i<=n;i++)//后i位
	// {
	// 	int x=(int)(S[n-i+1]-'0'),cnt=0;
	// 	psum+=x;
	// 	for (int j=0;j<=x-1;j++) cnt=(cnt+A[i-1][psum-j])%mod;
	// 	ans[i]=(cnt+ans[i-1])%mod;
	// }
	// cout<<ans[n]<<endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cal();
    int T = 1;
    cin >> T;
    for (int i=1;i<=T;i++) {
        try {
			cerr<<"Case #"<<i<<": "<<endl;
            solution();
        } catch (const char* e) {
            cerr << "Caught exception in solution: " << e << endl;
        }
    }
    return 0;
}

Details

answer.code:5:24: error: ‘#pragma GCC optimize’ string is badly formed
    5 | #pragma GCC optimize(3);
      |                        ^