CSES - HIIT Open 2019 - Results
Submission details
Task:Alien Invasion II
Sender:tykkipeli
Submission time:2019-05-25 11:38:55 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.03 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < luku.size(); i++) {
                     ~~^~~~~~~~~~~~~
input/code.cpp:21:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < luku.size(); i++) {
                     ~~^~~~~~~~~~~~~
input/code.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < luku.size()+1; i++) {
                     ~~^~~~~~~~~~~~~~~
input/code.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < luku.size()+1; i++) {
                     ~~^~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int osm[100];
char tulos[100];

int main() {
    string luku;
    cin >> luku;
    
    int summa = 0;
    for (int i = 0; i < luku.size(); i++) {
        summa += luku[i]-'0';
    }
    int a = 6 - summa%3;
    tulos[0] = a + '0';
    cout << tulos[0];
    for (int i = 0; i < luku.size(); i++) {
        tulos[i+1] = luku[i];
        cout << luku[i];
    }
    cout << endl;
    

    

    int yli = 0;
    for (int i = 0; i < luku.size()+1; i++) {
        int x = (yli *10 + tulos[i]-'0')/3;
        osm[i] = x;
        yli = (yli *10 + tulos[i]-'0') - 3*x;
    }
    cout << 3 << " ";
    for (int i = 0; i < luku.size()+1; i++) {
        if (i == 0 && osm[i] == '0') continue;
        cout << osm[i];
    }
    cout << endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
2368469234876449

correct output
22368469234876449
3 7456156411625483

user output
52368469234876449
3 17456156411625483

Test 2

Verdict: ACCEPTED

input
292929292929292929292929292931

correct output
129292929292929292929292929293...

user output
429292929292929292929292929293...

Test 3

Verdict: ACCEPTED

input
292929292929292929292929292979

correct output
129292929292929292929292929297...

user output
429292929292929292929292929297...