結果

問題 No.691 E869120 and Constructing Array 5
ユーザー ats5515ats5515
提出日時 2018-05-18 23:20:18
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,515 bytes
コンパイル時間 3,238 ms
コンパイル使用メモリ 81,260 KB
実行使用メモリ 12,984 KB
最終ジャッジ日時 2023-09-10 23:12:00
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
const int64_t CYCLES_PER_SEC = 2800000000;
const double TIMELIMIT = 8.3;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	void plus(double a) { start -= (a * CYCLES_PER_SEC); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
};
class XorShift {
public:
	unsigned int x, y, z, w;
	double nL[65536];

	XorShift()
	{
		init();
	}

	void init()
	{
		x = 314159265; y = 358979323; z = 846264338; w = 327950288;
		double n = 1 / (double)(2 * 65536);
		for (int i = 0; i < 65536; i++) {
			nL[i] = log(((double)i / 65536) + n);
		}
	}

	inline unsigned int next()
	{
		unsigned int t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
	}

	inline double nextLog() {
		return nL[next() & 0xFFFF];
	}

	inline int nextInt(int m)
	{
		return (int)(next() % m);
	}


	int nextInt(int min, int max)
	{
		return min + nextInt(max - min + 1);
	}


	inline double nextDouble()
	{
		return (double)next() / ((long long)1 << 32);
	}


};
XorShift rnd;
double calcSum(vector<int> &res) {
	double r = 0;
	for (int i = 0; i < res.size(); i++) {
		r += sqrt(res[i]);
	}
	return r;
}
Timer timer;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int Q;
	cin >> Q;
	vector<int> res;
	double sum = 0;
	double diff;
	for (int i = 0; i < Q; i++) {
		timer.reset();
		double P;
		cin >> P;
		res.clear();
		for (int i = 0; i < 29; i++) {
			res.push_back(100);
		}
		int a = (P - 10 * 29)* (P - 10 * 29);
		res.push_back(a);
		sum = calcSum(res);
		diff = abs(sum - P);
		double ss = sum - sqrt(res.back());
		int c = 0;
		while (true) {
			int x = rnd.nextInt(29);
			int d = rnd.nextInt(5) - 2;
			if (res[x] + d > 0) {
				ss += sqrt(res[x] + d) - sqrt(res[x]);
				res[x] += d;
				a = (P - ss)*(P - ss) + 0.5;
				res.back() = a;
				sum = ss + sqrt(res.back());
				
			}
			if (abs(sum - P) < 5e-11) break;
			//c++;
		}
		//cerr << "c=" << c << endl;
		//cerr <<setprecision(15) <<  sum << " " << calcSum(res) << endl;
		cout << 30;
		for (int i = 0; i < res.size(); i++) {
			cout << " " << res[i];
		}
		cout << endl;
	}
}
0