CSES - Datatähti 2017 loppu - Results
Submission details
Task:Ohjelma
Sender:Senpai
Submission time:2017-01-19 16:30:27 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:3: error: 'class std::vector<long long int>' has no member named 'reverse'
 v.reverse(v.begin(),v.end());
   ^

Code

#include <bits/stdc++.h>
using namespace std;
long long n,d;
vector<long long>v;
int main(){
cin>>n;
vector<string>m(3);
m[1]="ADD";
m[0]="MUL";
m[2]="END";

if(n%3==0){cout<<0;
return 0;}
if(n==1){
cout<<1<<endl;
cout<<"END";
return 0;}
while(n>1){

if(n%2==1  || n==4 ){n=n-3;
v.push_back(1);}
else if(n%2==0  && n!=4){n/=2;
v.push_back(0);}

}
v.reverse(v.begin(),v.end());
v.push_back(2);
d=v.size();
cout<<d<<"\n";
for(long long i=0; i<d; i++){
cout<<m[v[i]]<<"\n";
}
}