QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290170 | #6300. Best Carry Player 2 | zzuqy# | WA | 1ms | 3624kb | C++14 | 2.9kb | 2023-12-24 15:03:06 | 2023-12-24 15:03:07 |
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)
#define LL __int128
using namespace std;
const int MAXN = 40;
int T;
ll x, k;
int f[MAXN];
int g[MAXN];
LL F[MAXN][MAXN];
LL ans[MAXN];
void wri(LL x) {
if (!x)
return;
wri(x / 10);
putchar(x % 10 + '0');
}
int main() {
//freopen("1.in", "r", stdin);
sc(T);
ans[0] = 1;
while (T--) {
scl(x);
scl(k);
int lim = 37;
rep(0, 37, i) {
g[i] = x % 10;
x /= 10;
if (i >= 1)
ans[i] = ans[i - 1] * 10;
//wri(ans[i]);
//cout << g[i] << endl;
}
//wri(ans[1]);
if (k == 0) {
//cout << "ww" << endl;
rep(0, lim, i) {
if (g[i] != 9) {
wri(ans[i]);
break;
}
}
puts("");
continue;
}
//cout << "ww" << endl;
fep(37, 0, i) {
if (g[i + 1] == 9)
f[i] = f[i + 1] + 1;
else
f[i] = 1;
}
LL ww = 1, bb;
rep(1, lim, i)ww = ww * 10;
rep(0, lim, i)rep(1, 18, j)F[i][j] = ww;
int bv = -1;
rep(0, 38, k)if (g[k]) {
bv = k - 1;
break;
}
fep(lim, 0, i) {
//if(g[i]==0)continue;
if (i <= bv)
continue;
rep(1, lim, j) {
if (j >= f[i]) {
rep(i + f[i] + 1, lim, k) {
if (g[j - f[i]])
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, lim, i)if (g[i])
ww = min(ww, F[i][k]);
wri(ww);
puts("");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 1ms
memory: 3492kb
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 100000900001 9999910000 9999901000 9999900100 9999900010 9999900001 9000009999900001 99000009999900001 999000009999900001 99999999999999999900000000000000000 1000000000000000000
result:
wrong answer 11th lines differ - expected: '10000000001', found: '100000900001'