結果

問題 No.2125 Inverse Sum
ユーザー daiotadaiota
提出日時 2022-11-19 10:21:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 175,224 KB
実行使用メモリ 11,884 KB
最終ジャッジ日時 2023-10-20 16:15:15
合計ジャッジ時間 5,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 7 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 127 ms
11,884 KB
testcase_28 AC 111 ms
11,884 KB
testcase_29 AC 67 ms
11,868 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 111 ms
11,884 KB
testcase_32 AC 61 ms
11,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
typedef long long ll;
typedef pair<int,int> P;

vector<ll> div(ll n){
	vector<ll> d;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			d.push_back(i);
			if(i!=n/i) d.push_back(n/i);
		}
	}

	return d;
}

int main(void){
	ll i,j;

	cin.tie(0);  ios_base::sync_with_stdio(false);

	ll p,q;
	cin >> p >> q;

	vector<ll> a=div(q);
	vector<ll> b;
	ll s=a.size();
	for(i=0;i<s;i++){
		for(j=i;j<s;j++){
			b.push_back(a[i]*a[j]);
		}
	}

	sort(b.begin(),b.end());
	b.erase(unique(b.begin(),b.end()),b.end());
	ll t=b.size();

	vector<ll> n,m;
	ll T=0;
	for(i=0;i<t;i++){
		if((b[i]+q)%p==0 && (q*q/b[i]+q)%p==0){
			n.push_back((b[i]+q)/p);
			m.push_back((q*q/b[i]+q)/p);
			T++;
		}
	}

	cout << T << endl;
	REP(i,T){
		cout << n[i] << ' ' << m[i] << endl;
	}


	return 0;
}
0