Task: | Greater Integers |
Sender: | lookcook |
Submission time: | 2021-01-30 16:51:47 +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:16:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 1; i < s.length(); i++) { ~~^~~~~~~~~~~~
Code
#include <bits/stdc++.h>#define int long longusing namespace std;signed main() {ios_base::sync_with_stdio(0);cin.tie(0);int t;cin >> t;while (t--) {string s;cin >> s;bool flag = false;for (int i = 1; i < s.length(); i++) {if (s[i]-'0'<s[0]-'0') flag = true;else if (s[i]-'0'>s[0]-'0') break;}int sz = s.length();if (s[0] == '9' && !flag) sz++;int digit = s[0]-'0';if (!flag) {if (digit == 9) digit = 1;else digit++;}string res = "";for (int i = 0; i < sz; i++) res += (char)(digit+'0');cout << res << '\n';}}/**/
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 |