#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); // for fast io actions cin.tie(NULL); // init long long field_0[100][100]; long long field_1[100][100]; // input long long C = 0; cin >> C; long long CYCLE = 0; CYCLE = (long long) ceil(log(C) / log(5)); if (pow(5, CYCLE - 1) == C){ CYCLE = CYCLE - 1; } // output start // cut flowers cout << 10000 << endl; for (int i = 0; i < 100; ++i) { for (int j = 0; j < 100; ++j) { if (i == 50 && j == 50){ cout << i << " " << j << " " << 1 << endl; } else{ cout << i << " " << j << " " << 0 << endl; } } } // generate full field after CYCLE days field_0[50][50] = 1; for (int i = 0; i < CYCLE; ++i) { for (int j = 0; j < 100; ++j) { for (int k = 0; k < 100; ++k) { long long l, r, u, d; if (i % 2 == 0) { if (j - 1 < 0 || j - 1 >= 100) { l = 0; } else { l = field_0[j - 1][k]; } if (j + 1 < 0 || j + 1 >= 100) { r = 0; } else { r = field_0[j + 1][k]; } if (k - 1 < 0 || k - 1 >= 100) { u = 0; } else { u = field_0[j][k - 1]; } if (k + 1 < 0 || k + 1 >= 100) { d = 0; } else { d = field_0[j][k + 1]; } field_1[j][k] = field_0[j][k] + l + r + u + d; } else { if (j - 1 < 0 || j - 1 >= 100) { l = 0; } else { l = field_1[j - 1][k]; } if (j + 1 < 0 || j + 1 >= 100) { r = 0; } else { r = field_1[j + 1][k]; } if (k - 1 < 0 || k - 1 >= 100) { u = 0; } else { u = field_1[j][k - 1]; } if (k + 1 < 0 || k + 1 >= 100) { d = 0; } else { d = field_1[j][k + 1]; } field_0[j][k] = field_1[j][k] + l + r + u + d; } } } } set> visited; queue> q; q.push(pair(50,50)); vector> HARVESTED_PAIRS; int HARVESTED = 0; while(C != 0 && !q.empty()){ pair current_pair = q.front(); q.pop(); if (visited.find(current_pair) != visited.end()){ continue; } //cout << current_pair.first << " " << current_pair.second << endl; visited.insert(current_pair); if(CYCLE % 2 == 0){ if (C >= field_0[current_pair.first][current_pair.second]){ C -= field_0[current_pair.first][current_pair.second]; //cout << field_0[current_pair.first][current_pair.second] << endl; HARVESTED++; HARVESTED_PAIRS.push_back(current_pair); } } else{ if (C >= field_1[current_pair.first][current_pair.second]){ C -= field_1[current_pair.first][current_pair.second]; //cout << field_1[current_pair.first][current_pair.second] << endl; HARVESTED++; HARVESTED_PAIRS.push_back(current_pair); } } if (current_pair.first - 1 < 0 || current_pair.first - 1 >= 100){} else { q.push(pair(current_pair.first - 1, current_pair.second)); } if (current_pair.first + 1 < 0 || current_pair.first + 1 >= 100 || visited.find(pair(current_pair.first + 1, current_pair.second)) != visited.end()){} else { q.push(pair(current_pair.first + 1, current_pair.second)); } if (current_pair.second - 1 < 0 || current_pair.second - 1 >= 100 || visited.find(pair(current_pair.first, current_pair.second - 1)) != visited.end()){} else { q.push(pair(current_pair.first, current_pair.second - 1)); } if (current_pair.second + 1 < 0 || current_pair.second + 1 >= 100 || visited.find(pair(current_pair.first, current_pair.second + 1)) != visited.end()){} else { q.push(pair(current_pair.first, current_pair.second + 1)); } } // test print for (int i = 0; i < 100; ++i) { for (int j = 0; j < 100; ++j) { if (CYCLE % 2 == 0) { cout << " " << field_0[i][j] << " "; } else{ cout << " " << field_1[i][j] << " "; } } cout << endl; } /* long long sum = 0; int total = 0; for (int i = 0; i < 100; ++i) { for (int j = 0; j < 100; ++j) { if (CYCLE % 2 == 0) { sum += field_0[i][j]; if (field_0[i][j] != 0) total++; } else{ sum += field_1[i][j]; if (field_1[i][j] != 0) total++; } } } */ // output // harvested, days cout << HARVESTED << " " << CYCLE << endl; for (int i = 0; i < HARVESTED_PAIRS.size(); ++i) { cout << HARVESTED_PAIRS[i].first << " " << HARVESTED_PAIRS[i].second << endl; } //cout << CYCLE << endl; //cout << sum << endl; //cout << total << endl; //cout << C << endl; return 0; }