結果

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

テストケース

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

ソースコード

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;

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;
#define int long long
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;
	rnd.next();
	for (int i = 0; i < Q; i++) {
		double P;
		//cin >> P;
		P = rnd.nextDouble() * 4000 + 8000;
		res.clear();
		int a = (P / 30) * (P / 30);
		for (int i = 0; i < 30; i++) {
			res.push_back(a);
		}
		int c = 0;
		//cerr << calcSum(res) << " " << P << endl;
		double ss;
		//cerr << res.size() << endl;
		double tsum;
		double tss;
		while (true) {
			if((c & 0xFFFF) == 0){
				sum = calcSum(res);
				//cerr << sum << " " << P << endl;
			}
			int x = rnd.nextInt(30);
			
			if (sum < P) {
				sum -= sqrt(res[x]);
				res[x] += rnd.nextInt(5) + 1;
			}
			else {
				sum -= sqrt(res[x]);
				res[x] -= rnd.nextInt(5) + 1;
			}
			sum += sqrt(res[x]);
			if (abs(sum - P) < 1e-5) 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