QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712686 | #7996. 报数 IV | szy10010 | WA | 15ms | 22280kb | C++23 | 1.9kb | 2024-11-05 16:40:51 | 2024-11-05 16:40:56 |
Judging History
answer
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define pb emplace_back
#define pp pop_back()
#define int long long
#define laile cout<<"laile"<<endl
#define lowbit(x) ((x)&(-x))
#define double long double
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sd(x) scanf("%Lf",&x)
#define sdd(x,y) scanf("%Lf %Lf",&x,&y)
#define _for(i,n) for(int i=0;i<(n);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _pre(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
const int N=1e6+10,INF=4e18;
int n,m;
int g[10010][5];
int deal(int i)
{
int res=0;
while(i)
{
res+=i%10;
i/=10;
}
return res;
}
void init()
{
for(int i=1;i<=9000;i++)
{
int x=i;
g[i][0]=x;
x=deal(x),g[i][1]=x;
x=deal(x),g[i][2]=x;
x=deal(x),g[i][3]=x;
x=deal(x),g[i][4]=x;
}
return ;
}
int f[1010][9010][2];//前i位,值为j,贴上界状态为k的数字的个数
void solve()
{
string s;
int k;
cin>>s>>k>>m;
n=s.size();
s=" "+s;
f[0][0][1]=1;
_rep(i,1,n)
{
int x=s[i]-'0';
_rep(j,0,9000)
{
_rep(k,0,min(9ll,j))
{
f[i][j][0]+=f[i-1][j-k][0];
if(k<x)f[i][j][0]+=f[i-1][j-k][1];
else if(k==x)f[i][j][1]+=f[i-1][j-k][1];
}
}
}
k--;
k=min(k,4ll);
int res=0;
_rep(j,0,9000)
{
if(g[j][k]!=m)continue;
res+=f[n][j][0]+f[n][j][1];
}
cout<<res<<'\n';
return ;
}
signed main()
{
IOS;
int T=1;
init();
cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4336kb
input:
2 114 1 5 514 2 10
output:
8 10
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 22280kb
input:
5 114 1 5 514 2 10 114514 3 7 1919810 2 13 1145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810114514191981011451419198101145141919810 1 79
output:
8 10 260572 83597 -2745653145382017168
result:
wrong answer 3rd lines differ - expected: '12724', found: '260572'