結果

問題 No.550 夏休みの思い出(1)
ユーザー NamnamseoNamnamseo
提出日時 2017-07-30 13:34:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,570 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 13:19:11
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,248 KB
testcase_01 AC 10 ms
5,248 KB
testcase_02 AC 10 ms
5,376 KB
testcase_03 AC 9 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 10 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 9 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 10 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 10 ms
5,376 KB
testcase_23 AC 9 ms
5,376 KB
testcase_24 AC 9 ms
5,376 KB
testcase_25 AC 9 ms
5,376 KB
testcase_26 AC 9 ms
5,376 KB
testcase_27 AC 9 ms
5,376 KB
testcase_28 AC 9 ms
5,376 KB
testcase_29 AC 9 ms
5,376 KB
testcase_30 AC 9 ms
5,376 KB
testcase_31 AC 10 ms
5,376 KB
testcase_32 AC 10 ms
5,376 KB
testcase_33 AC 11 ms
5,376 KB
testcase_34 AC 10 ms
5,376 KB
testcase_35 AC 8 ms
5,376 KB
testcase_36 AC 8 ms
5,376 KB
testcase_37 AC 9 ms
5,376 KB
testcase_38 AC 10 ms
5,376 KB
testcase_39 AC 9 ms
5,376 KB
testcase_40 AC 10 ms
5,376 KB
testcase_41 AC 9 ms
5,376 KB
testcase_42 AC 9 ms
5,376 KB
testcase_43 AC 9 ms
5,376 KB
testcase_44 AC 9 ms
5,376 KB
testcase_45 AC 9 ms
5,376 KB
testcase_46 AC 8 ms
5,376 KB
testcase_47 AC 10 ms
5,376 KB
testcase_48 AC 10 ms
5,376 KB
testcase_49 AC 10 ms
5,376 KB
testcase_50 AC 9 ms
5,376 KB
testcase_51 AC 9 ms
5,376 KB
testcase_52 AC 10 ms
5,376 KB
testcase_53 AC 10 ms
5,376 KB
testcase_54 AC 10 ms
5,376 KB
testcase_55 AC 10 ms
5,376 KB
testcase_56 AC 9 ms
5,376 KB
testcase_57 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll A, B, C;

ll Pow(ll b, ll e, ll m){
	ll ret = 1;
	while(e){
		if(e&1) ret*=b, ret%=m;
		e/=2; b=b*b%m;
	}
	return ret;
}

vector<ll> sol_prime(ll p){
	vector<ll> ret;
	for(ll x=0; x<p; ++x){
		ll v = 0;
		v += Pow(x, 3, p);
		
		v += (A%p) * Pow(x, 2, p) % p;
		v %= p;
		v += (B%p) * x % p;
		v %= p;
		v += (C%p);
		v %= p;
		if(!v) ret.pb(x);
	}
	return ret;
}

ll modinv(ll x, ll p){
	return Pow(x, p-2, p);
}

// c is capital letter
ll China(ll p1, ll r1, ll p2, ll r2){
	auto f = [](ll myp, ll op){
		ll t = modinv(op%myp, myp);
		return op * t % (myp * op);
	};
	ll M = p1*p2;
	ll ret = (r1*f(p1, p2)%M + r2*f(p2, p1)%M) % M;
	return ret;
}

vector<ll> sol;
void Test(ll x, ll mod){
	ll bound = 1e9;
	while(-bound < x-mod) x-=mod;
	for(;x<bound;x+=mod){
		if(x == 0){
			if(C == 0){
				sol.pb(x);
			}
			continue;
		}
		if(abs(C)%abs(x)) continue;
		ll d=C/x;
		if(x*x + A*x + B == -d){
			sol.pb(x);
		}
	}
}

int main()
{
	cin >> A >> B >> C;
	ll p1 = 32707;
	ll p2 = 32801;
	auto v1=sol_prime(p1);
	auto v2=sol_prime(p2);
	for(ll r1:v1) for(ll r2:v2){
		Test(China(p1, r1, p2, r2), p1*p2);
	}
	sort(all(sol));
	for(ll x:sol) cout << x << ' ';
	return 0;
}
0