結果
| 問題 |
No.691 E869120 and Constructing Array 5
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2018-05-18 23:44:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,621 bytes |
| コンパイル時間 | 748 ms |
| コンパイル使用メモリ | 87,480 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 14:05:22 |
| 合計ジャッジ時間 | 14,298 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 27 |
ソースコード
#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;
}
}
ats5515