結果

問題 No.550 夏休みの思い出(1)
ユーザー kurenai3110kurenai3110
提出日時 2017-07-28 23:32:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,420 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 70,412 KB
実行使用メモリ 16,960 KB
最終ジャッジ日時 2024-04-19 20:38:08
合計ジャッジ時間 7,435 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0