QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#36208 | #4286. 99 Problems | cheems_is_hiring | WA | 2ms | 3608kb | C++ | 1.2kb | 2022-06-25 23:49:53 | 2022-06-25 23:49:55 |
Judging History
answer
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ii pair<ll,ll>
const ll mod = 1000007;
ii f(int init, int end, int h) {
if(h == 4) {
ll aa = init * end;
ll bb = (init+1) * (end - 1);
if(aa % mod == 0) {
aa = 1;
}
if(bb % mod == 0) {
bb = 1;
}
return ii(aa % mod , bb % mod);
}
int m = (init + end) / 2;
ii a = f(init, m, h/2);
ii b = f(m+1, end, h/2);
ll aa = a.first * b.second;
ll bb = a.second * b.first;
if(aa % mod== 0) {
aa = 1;
}
if(bb % mod == 0) {
bb = 1;
}
ll g = __gcd(aa,bb);
aa /= g; bb /= g;
return ii( aa % mod , bb % mod);
}
int getLen(int a) {
int l = 0;
while(a > 0) {
a /= 10;
l ++;
}
return l;
}
void sol() { // cheemsito
map<int,bool> M;
M[10] = M[100] = M[1000] = M[1000] = 1;
int x; cin >> x;
if(x < 10) {
cout << 9 << endl; return;
}
if(M[x]) {
cout << x - 1 << endl;
}
else {
int l = getLen(x);
while(x >= 10) {
x /= 10;
}
cout << x ;
for(int i = 0 ; i < l - 1 ; i ++) {
cout << '9';
}
cout << endl;
}
}
int main() {
int t; t = 1;
while (t--) sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3608kb
input:
10
output:
9
result:
wrong answer 1st lines differ - expected: '99', found: '9'