CSES - Datatähti 2018 alku - Results
Submission details
Task:Bittijono
Sender:inkeri
Submission time:2017-10-11 13:41:31 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:59:3: error: expected '}' at end of input
   }
   ^

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll tavoite;
cin >> tavoite;
if (tavoite == 1) {
cout << tavoite << endl;
return 0;
}
ll pituus = 1;
ll summa = 1;
ll a = 1;
ll b = 1;
while (summa < tavoite) {
pituus++;
ll c = a;
a += b;
b = c;
summa += a;
}
ll loppu = pow(2, pituus - 2);
queue<array<ll, 4>> jonot;
jonot.push({1, 2, 1, 1});
for (ll i = 1; i < loppu; i++) {
//cout << jonot.size() << endl;
array<ll, 4> arvot = jonot.front();
jonot.pop();
//lisätään 0
jonot.push({arvot[0] + arvot[1], arvot[1], arvot[1] + arvot[2], arvot[3]*2});
//lisätään 1
jonot.push({arvot[0] + arvot[2], arvot[1] + arvot[2], arvot[2], arvot[3]*2+1});
}
while (true) {
array<ll, 4> arvot = jonot.front();
jonot.pop();
ll maara1 = arvot[0] + arvot[1];
ll maara2 = arvot[0] + arvot[2];
if (maara1 == tavoite) {
ll arvo = 2 * arvot[3];
string jono = bitset<64>(arvo).to_string();
pituus = log(arvo)/log(2) + 1;
jono.erase(0, 64 - pituus);
cout << jono << endl;
return 0;
} if (maara2 == tavoite) {
ll arvo = 2 * arvot[3] + 1;
string jono = bitset<64>(arvo).to_string();
pituus = log(arvo)/log(2) + 1;
jono.erase(0, 64 - pituus);
cout << jono << endl;
return 0;
} if (maara1 < tavoite) {
jonot.push({maara1, arvot[1], arvot[1] + arvot[2], arvot[3]*2});
} if (maara2 < tavoite) {
jonot.push({maara2, arvot[1] + arvot[2], arvot[2], arvot[3]*2+1});
}
}