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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:21:17: error: expected ';' before ':' token
       summa += a:
                 ^

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:
  }
  queue<array<ll, 4>> jonot;
  //summa, prev0, prev1, arvo
  jonot.push({1, 2, 1, 1});
  for (ll i = 1; i < pow(2, pituus - 2); 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) {
          try {
              jonot.push({maara1, arvot[1], arvot[1] + arvot[2], arvot[3]*2});
          } catch (bad_alloc& ba) {
              cout << jonot.size() << endl;
              cout << maara1 << endl;
              cout << arvot[3]*2 << endl;
          }
      } if (maara2 < tavoite) {
          try {
            jonot.push({maara2, arvot[1] + arvot[2], arvot[2], arvot[3]*2+1});
          } catch (bad_alloc& ba) {
              cout << jonot.size() << endl;
              cout << maara2 << endl;
              cout << arvot[3]*2 << endl;
          }
      }
  }
}