Task: | Greater Integers |
Sender: | nirjhor |
Submission time: | 2021-01-29 18:23:57 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 35 |
#2 | ACCEPTED | 65 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while (at < dig.size() and dig[at] == dig[0]) ++at; ~~~^~~~~~~~~~~~ input/code.cpp:21:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (at == dig.size()) { ~~~^~~~~~~~~~~~~ input/code.cpp:23:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i <= dig.size(); ++i) putchar('1'); ~~^~~~~~~~~~~~~ input/code.cpp:26:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < dig.size(); ++i) printf("%d", dig[0] + 1); ~~^~~~~~~~~~~~ input/code.cpp:31:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < dig.size(); ++i) printf("%d", who);...
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; int t; ll n; int main() { cin >> t; while (t--) { cin >> n; vector <int> dig; while (n) { dig.emplace_back(n % 10); n /= 10; } reverse(dig.begin(), dig.end()); int at = 0; while (at < dig.size() and dig[at] == dig[0]) ++at; if (at == dig.size()) { if (dig[0] == 9) { for (int i = 0; i <= dig.size(); ++i) putchar('1'); puts(""); } else { for (int i = 0; i < dig.size(); ++i) printf("%d", dig[0] + 1); puts(""); } } else { int who = (dig[at] > dig[0]) ? dig[0] + 1 : dig[0]; for (int i = 0; i < dig.size(); ++i) printf("%d", who); puts(""); } } return 0; }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
1000 1 2 3 4 ... |
correct output |
---|
2 3 4 5 6 ... |
user output |
---|
2 3 4 5 6 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 735425311146082632 756615631808964686 466489470801941584 100417544394053220 ... |
correct output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 555555555555555555 ... |
user output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 55555555555555 ... Truncated |