QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310648 | #5236. Wersja dla profesjonalistów [A] | sumi007 | 0 | 0ms | 0kb | C++14 | 1.3kb | 2024-01-21 16:36:06 | 2024-01-21 16:36:06 |
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ldb long double
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define lowbit(i) i&(-i)
ll n,pw9[30];
string get_str(ll k,string x){
if(k<=9){
char t = '0'+k;
if(k==1) return x;
string res = t+x;
return res;
}
ll lg=0,n=k,m;string ex="";
if(!k) return ex;
while(n>=9) n /= 9,lg++;
if(lg){
for(int i=1;i<=lg;i++) ex = ex+"9[";
m = k/pw9[lg];
char t = '0'+m;
if(m==1) ex = ex+x;
else ex = ex+t,ex = ex+x;
for(int i=1;i<=lg;i++) ex = ex+"]";
}
k -= m*pw9[lg];
ex = ex+get_str(k,x);
return ex;
}
string solve(ll n){
if(n==1){
return "AE";
}
if(n%2==0){
string res = solve(n-1),ex;
//(n-1)[AC]C(n)E
ex = get_str(n-1,"[AC]")+"A"+get_str(n,"E");
res = res+ex;
return res;
}
string res = solve(n/2),ex;
res = "2["+res+"]";
ex = get_str(n/2,"[AC]")+"A";
ex = ex+get_str(n/2,"["+get_str(n/2,"[CE]")+"C"+get_str((n+1)/2,"A")+"]");
ex = ex+get_str(n,"E");
res = res+ex;
return res;
}
int main(){
freopen("ans.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n;
pw9[0] = 1;
for(int i=1;i<=25;i++) pw9[i] = pw9[i-1]*9ll;
string ans = solve(n);
ans = ans+get_str(n,"C");
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Dangerous Syscalls
Test #1:
score: 0
Dangerous Syscalls
input:
1
output:
result:
Subtask #2:
score: 0
Dangerous Syscalls
Test #16:
score: 0
Dangerous Syscalls
input:
320
output:
result:
Subtask #3:
score: 0
Dangerous Syscalls
Test #28:
score: 0
Dangerous Syscalls
input:
1000000
output:
result:
Subtask #4:
score: 0
Dangerous Syscalls
Test #37:
score: 0
Dangerous Syscalls
input:
999999
output:
result:
Subtask #5:
score: 0
Dangerous Syscalls
Test #46:
score: 0
Dangerous Syscalls
input:
10000000000
output:
result:
Subtask #6:
score: 0
Dangerous Syscalls
Test #55:
score: 0
Dangerous Syscalls
input:
9999999999
output:
result:
Subtask #7:
score: 0
Dangerous Syscalls
Test #64:
score: 0
Dangerous Syscalls
input:
100000000000000
output:
result:
Subtask #8:
score: 0
Dangerous Syscalls
Test #84:
score: 0
Dangerous Syscalls
input:
99999999999999
output:
result:
Subtask #9:
score: 0
Dangerous Syscalls
Test #103:
score: 0
Dangerous Syscalls
input:
1000000000000000000
output:
result:
Subtask #10:
score: 0
Dangerous Syscalls
Test #128:
score: 0
Dangerous Syscalls
input:
999999999999999999