結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2017-07-28 23:32:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,420 bytes |
| コンパイル時間 | 894 ms |
| コンパイル使用メモリ | 70,248 KB |
| 実行使用メモリ | 16,840 KB |
| 最終ジャッジ日時 | 2024-10-11 12:54:28 |
| 合計ジャッジ時間 | 7,768 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 54 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <chrono>
using namespace std;
//タイマー
class Timer {
chrono::high_resolution_clock::time_point start, end;
double limit;
public:
Timer() {
start = chrono::high_resolution_clock::now();
}
Timer(double l) {
start = chrono::high_resolution_clock::now();
limit = l;
}
double getTime() {
end = chrono::high_resolution_clock::now();
return chrono::duration<double>(end - start).count();
}
bool Over() {
if (getTime() > limit) {
return true;
}
return false;
}
void setLimit(double l) {
limit = l;
}
void setStart() { start = chrono::high_resolution_clock::now(); }
};
//疑似乱数
class Xor128 {
unsigned static int x, y, z, w;
public:
Xor128() {
x = 31103110, y = 123456789, z = 521288629, w = 88675123;
}
unsigned int rand()
{
unsigned int t;
t = (x ^ (x << 11)); x = y; y = z; z = w;
return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
};
unsigned int Xor128::x, Xor128::y, Xor128::z, Xor128::w;
long long powll(long long a, int n) {
long long res = 1;
for (int i = 0; i < n; i++) {
res *= a;
}
return res;
}
void three_sort(long long& a, long long& b, long long& c) {
}
int main()
{
Xor128 xor128;
long long A, B, C;
cin >> A >> B >> C;
vector<pair<int, int>>prime;
long long x;
if(C!=0)x = (C > 0 ? C : -C);
else x = (B > 0 ? B : -B);
for (long long i = 2; i*i <= x; i++) {
if (x%i == 0) {
int cnt = 0;
while (x%i == 0) {
x /= i;
cnt++;
}
prime.push_back(make_pair(i,cnt));
}
}
if(x!=1)prime.push_back(make_pair(x, 1));
long long a,b,c;
while (1) {
a = (C!=0), b = 1, c = 1;
for (int i = 0; i < prime.size(); i++) {
int ra=0, rb=0, rc=0;
if(C!=0)ra = xor128.rand() % (prime[i].second - ra - rb - rc + 1);
rb = xor128.rand() % (prime[i].second - ra - rb - rc + 1);
rc = xor128.rand() % (prime[i].second - ra - rb - rc + 1);
if (C != 0)a *= powll(prime[i].first, ra);
b *= powll(prime[i].first, rb);
c *= powll(prime[i].first, rc);
}
if (C != 0)if (xor128.rand() % 2)a *= -1;
if (xor128.rand() % 2)b *= -1;
if (C != 0) {
if (a*b*c != -C)c *= -1;
}
else {
if (b*c != B)b *= -1;
}
if (a + b + c == -A && a*b + b*c + c*a == B) {
if (b > c)swap(b, c);
if (a > b)swap(a, b);
if (b > c)swap(b, c);
break;
}
}
cout << a << " " << b << " " << c << endl;
return 0;
}
kurenai3110