QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290141 | #6300. Best Carry Player 2 | zzuqy# | WA | 0ms | 3740kb | C++14 | 2.7kb | 2023-12-24 14:13:41 | 2023-12-24 14:13:41 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#define ll long long
#define db double
#define INF 5000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define m(w) t[w].m
#define mn(w) t[w].mn
#define c(w) t[w].c
#define s(w) t[w].s
#define tag(w) t[w].tag
#define S second
#define mod 1000000007
#define sc(A) scanf("%d",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define zz p<<1
#define yy p<<1|1
#define fep(p,n,cc) for(int cc=p;cc>=n;--cc)
#define scl(A) scanf("%lld",&A)
using namespace std;
const int MAXN = 20;
int T;
ll x,k;
int f[MAXN];
int g[MAXN];
ll F[MAXN][MAXN];
ll G[MAXN][MAXN];
ll ans[MAXN];
int main()
{
//freopen("1.in", "r", stdin);
sc(T);
ans[0]=1;
while(T--)
{
scl(x);scl(k);
rep(0,17,i)
{
g[i]=x%10;
x/=10;
if(i>=1)ans[i]=ans[i-1]*10;
}
ans[18]=ans[17]*10;
if(k==0)
{
rep(0,17,i)
{
if(g[i]!=9)
{
putl(ans[i]);
break;
}
}
continue;
}
fep(17,0,i)
{
if(g[i+1]==9)f[i]=f[i+1]+1;
else f[i]=1;
}
ll ww=2000000000000000000ll;
rep(0,18,i)rep(1,18,j)F[i][j]=ww;
fep(17,0,i)
{
rep(1,18,j)
{
if(j>=f[i])
{
rep(i+f[i]+1,17,k)F[i][j]=min(F[i][j],F[k][j-f[i]]+(10-g[i])*ans[i]);
if(j-f[i]==0)
{
F[i][j]=min(F[i][j],F[i+f[i]][j-f[i]]+(10-g[i])*ans[i]);
}
else F[i][j]=min(F[i][j],F[i+f[i]][j-f[i]]+(10-g[i])*ans[i]-ans[i+f[i]]);
}
}
}
rep(0,17-k+1,i)ww=min(ww,F[i][k]);
putl(ww);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
4 12345678 0 12345678 5 12345678 18 990099 5
output:
1 54322 999999999987654322 9910
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3720kb
input:
21 999990000099999 0 999990000099999 1 999990000099999 2 999990000099999 3 999990000099999 4 999990000099999 5 999990000099999 6 999990000099999 7 999990000099999 8 999990000099999 9 999990000099999 10 999990000099999 11 999990000099999 12 999990000099999 13 999990000099999 14 999990000099999 15 999...
output:
100000 10000 1000 100 10 1 900001 9900001 99900001 999900001 10000000000 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 900000000000000000
result:
wrong answer 11th lines differ - expected: '10000000001', found: '10000000000'