結果

問題 No.2125 Inverse Sum
ユーザー ixTL255ixTL255
提出日時 2022-12-31 15:36:44
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 11,939 ms
コンパイル使用メモリ 374,252 KB
実行使用メモリ 13,644 KB
最終ジャッジ日時 2024-11-26 13:05:06
合計ジャッジ時間 71,483 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

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