| Task: | Suuremmat |
| Sender: | T |
| Submission time: | 2021-01-23 16:25:54 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
| #2 | WRONG ANSWER | 0.01 s | 2 | details |
Code
/**
* Datatähti 2021 loppu
* 358
* A
* Suuremmat
* @author TRS
*/
//Include
#include <bits/stdc++.h>
//Definitions
using namespace std;
//Constants
#define infinity 0x3f3f3f3f
#define linfinity 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
int t;
unsigned long long n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>t;
for (int _ = 0; _ < t; _++) {
cin>>n;
if (n < 9) {
cout<<(n + 1)<<"\n";
}
else if (n < 11) {
cout<<11<<"\n";
}
else {
int maxPowerOf10 = floor(log10(n));
short firstDigit = floor(n / pow(10, maxPowerOf10));
short secondDigit = (int)floor(n / pow(10, maxPowerOf10 - 1)) % 10;
if (firstDigit > secondDigit) {
for (int d = 0; d <= maxPowerOf10; d++) {
cout<<firstDigit;
}
}
else if (firstDigit < secondDigit) {
for (int d = 0; d <= maxPowerOf10; d++) {
cout<<secondDigit;
}
}
else {
int hasGreaterDigitAtEnd = 0;
for (int d = 0; d <= maxPowerOf10 + 1; d++) {
int digit = n % 10;
n /= 10;
if (digit > firstDigit) {
hasGreaterDigitAtEnd = 1;
break;
}
}
if (hasGreaterDigitAtEnd) {
for (int d = 0; d <= maxPowerOf10; d++) {
cout<<(firstDigit + 1);
}
}
else {
for (int d = 0; d <= maxPowerOf10; d++) {
cout<<firstDigit;
}
}
}
cout<<"\n";
}
}
return 0;
}
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
| 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: WRONG ANSWER
| input |
|---|
| 1000 735425311146082632 756615631808964686 466489470801941584 100417544394053220 ... |
| correct output |
|---|
| 777777777777777777 777777777777777777 555555555555555555 111111111111111111 555555555555555555 ... |
| user output |
|---|
| 777777777777777777 777777777777777777 666666666666666666 111111111111111111 77777777777777 ... Truncated |
