QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404715 | #7606. Digital Nim | ucup-team3396# | WA | 1ms | 3732kb | C++14 | 1.6kb | 2024-05-04 15:13:10 | 2024-05-04 15:13:12 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void write(ll x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
ll T,n,pw[20];
ll calc(ll x){
ll res=0;
while(x)res+=x%10,x/=10;
return res;
}
ll work(ll n,ll x,ll c);
unordered_map<ll,ll>mp;
ll oni(ll n,ll o,ll p,ll q){
ll sta=n*200*200*200+o*200*200+p*200+q;
if(mp.count(sta))return mp[sta];
ll v=work(n*pw[o]-1,p,q);
ll res=(v+1>(n+p)/10?0:v+1);
return mp[sta]=res;
}
ll work(ll n,ll x,ll c){
if(!n)return c;
ll lg=0;
while(pw[lg+1]<=n)lg++;
ll v=oni(n/pw[lg],lg,x,c);
return work(n%pw[lg],x+n/pw[lg],v);
}
ll solve(ll debug=0){
if(debug){
n=debug;
if(n%10)return 1;
else if(work(n/10,0,0))return 1;
return 0;
}
n=read();
if(n%10)puts("Algosia");
else {
if(work(n/10,0,0))puts("Alogsia");
else puts("Bajtek");
}
return 0;
}
bool Med;
int main(){
// freopen("a.out","w",stdout);
pw[0]=1;
rep(i,1,18)pw[i]=pw[i-1]*10;
cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
T=read();
while(T--)solve();
// rep(i,1,1000){
// if(solve(i*10))cout<<i<<endl;
// }
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3732kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Alogsia
result:
wrong answer 4th lines differ - expected: 'Algosia', found: 'Alogsia'