QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227286 | #7606. Digital Nim | ucup-team1004# | WA | 2ms | 6932kb | C++14 | 1.5kb | 2023-10-27 09:58:19 | 2023-10-27 09:58:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
int count(ll n){
int ans=0;
for(;n;n/=10)ans+=n%10;
return ans;
}
ll nex(ll n,int s=0){
for(ll i=n+10;;i+=10){
if(i-count(i)-s>n)return i;
}
return -1;
}
const int N=20,M=200;
int T,his[N][M][M];
ll n,pw[N];
int nex(int d,int s,int i){
int las=i;
if(~his[d][s][las])return his[d][s][las];
if(d<3){
for(;i<pw[d+1];i=nex(i,s));
return his[d][s][las]=i-pw[d+1];
}
for(;i/pw[d]<9;){
int x=nex(d-1,s+i/pw[d],i%pw[d]);
i+=x-i%pw[d]+pw[d];
}
return his[d][s][las]=nex(d-1,s+i/pw[d],i%pw[d]);
}
void get(){
scanf("%lld",&n);
if(n%10){
puts("Algosia");return;
}
ll i=0;
for(int d=18;d>=3;d--){
for(;i/pw[d]%10<n/pw[d]%10;){
// debug(i,d-1,count(i/pw[d]),i%pw[d],nex(d-1,count(i/pw[d]),i%pw[d]));
i=i+nex(d-1,count(i/pw[d]),i%pw[d])-i%pw[d]+pw[d];
// debug(i);
}
}
for(;i<n;i=nex(i));
puts(i==n?"Bajtek":"Algosia");
// if(i^n)debug(i,n);
}
int main(){
memset(his,-1,sizeof his);
for(int i=pw[0]=1;i<=18;i++)pw[i]=pw[i-1]*10;
for(scanf("%d",&T);T--;)get();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6724kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Algosia
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 6932kb
input:
1 1
output:
Algosia
result:
ok single line: 'Algosia'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 6800kb
input:
10000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
output:
Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia...
result:
wrong answer 10000th lines differ - expected: 'Bajtek', found: 'Algosia'