QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#639699 | #1752. Ballpark Estimate | oxford01# | AC ✓ | 0ms | 3848kb | C++20 | 1.2kb | 2024-10-13 21:38:30 | 2024-10-13 21:38:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (auto i = a; i < (b); ++i)
#define repr(i, a, b) for (auto i = (a) - 1; i >= (b); --i)
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pii>;
template<class T>
inline bool cmax(T &a, const T& b) {
return a < b ? a = b, 1 : 0;
}
template<class T>
inline bool cmin(T &a, const T &b) {
return b < a ? a = b, 1 : 0;
}
const int inf = 0x3f3f3f3f;
const ll linf = 1e18;
const double dinf = numeric_limits<double>::infinity();
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
string s;
cin >> s;
int sz = s.size();
string t = s;
for (int i = 1; i < sz; i++) {
t[i] = '0';
}
ll n1 = stoll(t);
ll po = 1;
for (int i = 0; i < sz-1; i++) po *= 10;
ll n2 = n1+po;
ll res = n2;
ll n = stoll(s);
if (abs(n-n1) < abs(n-n2)) res = n1;
cout << res << endl;
}
/*
4 100
44 35 66 67
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
533839461958894364
output:
500000000000000000
result:
ok single line: '500000000000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
253879280762610326
output:
300000000000000000
result:
ok single line: '300000000000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
861411989833943880
output:
900000000000000000
result:
ok single line: '900000000000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
5
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
9
output:
9
result:
ok single line: '9'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
11
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
15
output:
20
result:
ok single line: '20'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
49
output:
50
result:
ok single line: '50'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1497
output:
1000
result:
ok single line: '1000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
6583
output:
7000
result:
ok single line: '7000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
8967
output:
9000
result:
ok single line: '9000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
9758
output:
10000
result:
ok single line: '10000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
10772
output:
10000
result:
ok single line: '10000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
11644
output:
10000
result:
ok single line: '10000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
20851
output:
20000
result:
ok single line: '20000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
21166
output:
20000
result:
ok single line: '20000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
24183
output:
20000
result:
ok single line: '20000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
28860
output:
30000
result:
ok single line: '30000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
32184
output:
30000
result:
ok single line: '30000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
32325
output:
30000
result:
ok single line: '30000'