結果

問題 No.691 E869120 and Constructing Array 5
ユーザー square1001square1001
提出日時 2018-05-18 23:43:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 1,251 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 80,636 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-11 00:11:08
合計ジャッジ時間 4,069 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
4,384 KB
testcase_01 AC 57 ms
4,380 KB
testcase_02 AC 46 ms
4,380 KB
testcase_03 AC 44 ms
4,384 KB
testcase_04 AC 45 ms
4,380 KB
testcase_05 AC 44 ms
4,380 KB
testcase_06 AC 64 ms
4,380 KB
testcase_07 AC 44 ms
4,384 KB
testcase_08 AC 45 ms
4,380 KB
testcase_09 AC 44 ms
4,380 KB
testcase_10 AC 47 ms
4,380 KB
testcase_11 AC 45 ms
4,380 KB
testcase_12 AC 46 ms
4,380 KB
testcase_13 AC 45 ms
4,380 KB
testcase_14 AC 46 ms
4,384 KB
testcase_15 AC 46 ms
4,380 KB
testcase_16 AC 47 ms
4,384 KB
testcase_17 AC 45 ms
4,508 KB
testcase_18 AC 47 ms
4,380 KB
testcase_19 AC 45 ms
4,380 KB
testcase_20 AC 47 ms
4,380 KB
testcase_21 AC 43 ms
4,384 KB
testcase_22 AC 45 ms
4,380 KB
testcase_23 AC 44 ms
4,384 KB
testcase_24 AC 45 ms
4,380 KB
testcase_25 AC 44 ms
4,380 KB
testcase_26 AC 45 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
using namespace std;
int q; long double x;
int main() {
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x;
		int sz = 7;
		int lim = x * x / (4 * sz * sz) + 1.00001L;
		for (int j = lim; ; j++) {
			long double bs = sqrt((long double)(j));
			long double rem = sqrt((long double)(j)) * (2 * sz) - x;
			vector<int> delta(sz);
			for (int k = 0; k < sz; k++) {
				int l = 0, r = j;
				while (r - l > 1) {
					int m = (l + r) >> 1;
					if (rem > 2 * bs - sqrt((long double)(j - m)) - sqrt((long double)(j + m))) l = m;
					else r = m;
				}
				rem -= 2 * bs - sqrt((long double)(j - l)) - sqrt((long double)(j + l));
				delta[k] = l;
			}
			if (rem < 1.0e-10L) {
				vector<long double> ret(2 * sz);
				for (int k = 0; k < sz; k++) {
					ret[2 * k] = j - delta[k];
					ret[2 * k + 1] = j + delta[k];
				}
				long double val = 0.0;
				for (int k = 0; k < ret.size(); k++) {
					val += sqrt(ret[k]);
				}
				cerr << fixed << setprecision(15) << j << ' ' << lim << ' ' << val << ' ' << abs(val - x) << endl;
				cout << ret.size();
				for (int k = 0; k < ret.size(); k++) {
					cout << ' ' << ret[k];
				}
				cout << '\n';
				break;
			}
		}
	}
	return 0;
}
0