CSES - Datatähti Open 2021 - Results
Submission details
Task:Greater Integers
Sender:jenkinsser
Submission time:2021-01-31 13:00:42 +0200
Language:C++17
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED35
#2ACCEPTED65
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:56:16: warning: statement has no effect [-Wunused-value]
             ans;
                ^

Code

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define N 2000005
#define INF 1e9+5
#define sp " "
#define nl "\n"
#define all(x) x.begin(),x.end()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define fori(i,l,r) for(int i=l;i<=r;i++)
#define forf(i,r) fori(i,1,r)
#define rof(i,r,l) for(int i=r;i>=l;i--)
#define ll long long
#define int ll
using namespace std;

int binpow(int x,int y){
    int ans=1;
    for(;y>0;x*=x,y>>=1){
        if(y&1)
            ans*=x;
    }
    return ans;
}

void solve(){
	int n;
	cin >> n;
	int dig=0;
	int f;
	int tmp=n;
	int ans=0;
	bool flag=false;
	while(n){
		dig++;
		f=n%10;
		if(f!=9)
            flag=true;
		n/=10;
	}
	if(!flag){
        for(int i=0;i<=dig;i++){
            cout << 1;
        }
        cout << nl;
        return;
	}
	else{
        for(int i=0;i<dig;i++){
            ans+=f*binpow(10,i);
        }
        if(ans>tmp)
            ans;
        else{
            for(int i=0;i<dig;i++){
                ans+=binpow(10,i);
            }
        }
        cout << ans << nl;
	}
}

int32_t main(){
	fastio()
	int t;
	cin >> t;
	while(t--){
		solve();
	}
}

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
...

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
555555555555555555
...