#include using namespace std; static const int MOD = 100000000; static const int N = 50; static const double TIME_LIMIT = 1.9; static long long A[N + 1][N + 1]; long long diff_error(long long x, long long y) { long long d = llabs(x - y); if (d >= MOD) d %= MOD; return min(d, MOD - d); } long long compute_cost(const vector &c) { static long long b[N + 1][N + 1]; for (int j = 1; j <= N; j++) { b[N][j] = c[j - 1]; } for (int i = N - 1; i >= 1; i--) { for (int j = 1; j <= i; j++) { long long tmp = b[i + 1][j] + b[i + 1][j + 1]; if (tmp >= MOD) tmp -= MOD; b[i][j] = tmp; } } long long mx = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= i; j++) { long long e = diff_error(A[i][j], b[i][j]); if (e > mx) mx = e; } } return mx; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tmpN; cin >> tmpN; for (int i = 1; i <= N; i++) { for (int j = 1; j <= i; j++) { cin >> A[i][j]; } } std::random_device rd; std::mt19937_64 mt(rd()); uniform_int_distribution distC(0, MOD - 1); vector c(N); for (int i = 0; i < N; i++) { c[i] = distC(mt); } long long current_cost = compute_cost(c); cerr << "initial cost: " << current_cost << endl; vector best_c = c; long long best_cost = current_cost; auto start_clock = chrono::system_clock::now(); const double T0 = 1e7; const double T_end = 1e3; int iter = 0; while (true) { auto now_clock = chrono::system_clock::now(); double elapsed = chrono::duration(now_clock - start_clock).count(); if (elapsed > TIME_LIMIT) break; double progress_ratio = elapsed / TIME_LIMIT; double T = T0 * pow(T_end / T0, progress_ratio); // ランダムな位置を選び、違う値に入れ替える近傍 int p = uniform_int_distribution(0, N - 1)(mt); int prev = c[p]; c[p] = distC(mt); long long new_cost = compute_cost(c); long long diff = new_cost - current_cost; if (diff < 0 || uniform_real_distribution(0, 1)(mt) < exp(-diff / T)) { cerr << "update: " << current_cost << endl; current_cost = new_cost; if (current_cost < best_cost) { best_cost = current_cost; best_c = c; } } else { c[p] = prev; } iter++; } cerr << "best cost: " << best_cost << endl; cerr << "iteration: " << iter << endl; for (int i = 0; i < N; i++) { cout << best_c[i] << (i + 1 < N ? ' ' : '\n'); } return 0; }