#include using namespace std; #define FOR(i, s, n) for(int i = s; i < n; ++i) #define PB push_back #define EB emplace_back #define MP make_pair #define F first #define S second #define MAX 0x3f3f3f3 #define MAXN 10100 #define ll long long #define PII pair #define MAX_POT_2 110 #define WIDTH 200 #define ROWS 1000 ll n; int days; ll halfRow[WIDTH/2]; vector toHarvest; /* ll pot2Res[MAX_POT_2]; vector pots2ToSum; void calculatePots2ToSum(ll pot2) { ll remaining = n; for (int pot2Temp = pot2; pot2Temp >= 0; --pot2Temp) { if (pot2Res[pot2Temp] <= remaining) { remaining -= pot2Res[pot2Temp]; pots2ToSum.EB(pot2Temp); } } } */ bool isSolveable() { ll remaining = n; int harvestedCount = 0; FOR (i, 0, WIDTH/2) { harvestedCount = 0; while (remaining >= halfRow[i] && harvestedCount < ROWS * 2) { // TODO: optimizacija: matematika, mnozenje remaining -= halfRow[i]; harvestedCount++; } } return remaining == 0; } void stepOneDay() { ++days; ll lastOriginal = halfRow[0]; ll temp; FOR (i, 0, WIDTH/2 - 1) { temp = halfRow[i]; halfRow[i] += lastOriginal + halfRow[i+1]; lastOriginal = temp; if (halfRow[i] == 1) { break; } } } void harvest() { ll remaining = n; int row; FOR (i, 0, WIDTH/2) { FOR (side, 0, 2) { row = 0; while (remaining && remaining >= halfRow[i] && row < ROWS) { remaining -= halfRow[i]; if (side == 0) { toHarvest.EB(MP(i, row*2)); } else { toHarvest.EB(MP(-i-1, row*2)); } ++row; } } } } void printHalfRow() { FOR (i, 0, 20) { cout<>n; /* pot2Res[0] = 1; FOR (i, 1, MAX_POT_2) { pot2Res[i] = pot2Res[i-1] * 2; } */ /* ll pot2 = 0; while (pot2Res[pot2] < n) { ++pot2; } calculatePots2ToSum(pot2); */ /* for (ll l : pots2ToSum) { cout< n == 0, n == 1 ili n == 10^18 cout<