結果

問題 No.691 E869120 and Constructing Array 5
ユーザー square1001square1001
提出日時 2018-05-18 23:33:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 1,249 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 80,600 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 00:10:51
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
4,380 KB
testcase_01 AC 151 ms
4,380 KB
testcase_02 AC 103 ms
4,376 KB
testcase_03 AC 102 ms
4,380 KB
testcase_04 AC 103 ms
4,380 KB
testcase_05 AC 103 ms
4,376 KB
testcase_06 AC 103 ms
4,376 KB
testcase_07 AC 104 ms
4,376 KB
testcase_08 AC 104 ms
4,376 KB
testcase_09 AC 106 ms
4,380 KB
testcase_10 AC 106 ms
4,376 KB
testcase_11 AC 104 ms
4,380 KB
testcase_12 AC 104 ms
4,380 KB
testcase_13 AC 103 ms
4,376 KB
testcase_14 AC 103 ms
4,380 KB
testcase_15 AC 103 ms
4,376 KB
testcase_16 AC 104 ms
4,380 KB
testcase_17 AC 102 ms
4,376 KB
testcase_18 AC 104 ms
4,380 KB
testcase_19 AC 103 ms
4,376 KB
testcase_20 AC 104 ms
4,380 KB
testcase_21 AC 103 ms
4,380 KB
testcase_22 AC 107 ms
4,380 KB
testcase_23 AC 104 ms
4,376 KB
testcase_24 AC 105 ms
4,380 KB
testcase_25 AC 104 ms
4,380 KB
testcase_26 AC 104 ms
4,380 KB
testcase_27 AC 2 ms
4,376 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 = 10;
		int lim = x * x / (4 * sz * sz) + 1.01L;
		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