結果

問題 No.2125 Inverse Sum
ユーザー ixTL255ixTL255
提出日時 2022-12-31 15:36:44
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 151,176 KB
実行使用メモリ 9,008 KB
最終ジャッジ日時 2023-08-17 15:50:12
合計ジャッジ時間 7,074 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,360 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn divisors(n: i64) -> Vec<i64> {
	let mut d = Vec::new();
	for i in 1..=(f64::sqrt(n as f64) + 1e-18) as i64 {
		if n % i == 0 {
			d.push(i);
			if i != n / i {
				d.push(n / i);
			}
		}
	}
	d.sort();
	d
}

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	let mut itr = s.trim().split_whitespace();
	let p: i64 = itr.next().unwrap().parse().unwrap();
	let q: i64 = itr.next().unwrap().parse().unwrap();

	let mut ans = Vec::new();
	for x in divisors(q * q) {
		let y = q * q / x;
		if (x + q) % p ==0 && (y + q) % p == 0 {
			ans.push(((x + q) / p, (y + q) / p));
		}
	}
	ans.sort_unstable();
	println!("{}", ans.len());
	if !ans.is_empty(){
		for i in ans.iter() {
			println!("{} {}", i.0, i.1);
		}
	}
}
0