QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#36208#4286. 99 Problemscheems_is_hiringWA 2ms3608kbC++1.2kb2022-06-25 23:49:532022-06-25 23:49:55

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-25 23:49:55]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3608kb
  • [2022-06-25 23:49:53]
  • 提交

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'