CSES - Datatähti 2023 alku - Results
Submission details
Task:Kertoma
Sender:Turhake
Submission time:2022-11-07 15:52:45 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:7:9: error: 'i' was not declared in this scope
    7 |     for(i=0; i<=9; i++)
      |         ^
input/code.cpp:9:9: error: 'i' was not declared in this scope
    9 |     for(i=0; i<=9; i++)
      |         ^

Code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int luvut[9], s=0, n=2;
    float summa=0;
    for(i=0; i<=9; i++)
        cin>>luvut[i];
    for(i=0; i<=9; i++)
        s=s+luvut[i];
    while(!(floor(summa+1)==s))
    {
        summa=summa+log10(n);
        n++;
    }
    if(s==1)
    {
        if(luvut[6]==1)
            cout<<3;
        if(luvut[2]==1)
            cout<<2;
    }
    if(s==3)
    {
        if(luvut[1]==1)
            cout<<5;
        if(luvut[7]==1)
            cout<<6;
    }
    if(s>3)
        cout<<n-1;
}