結果
問題 |
No.1218 Something Like a Theorem
|
ユーザー |
![]() |
提出日時 | 2020-09-21 15:39:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 787 bytes |
コンパイル時間 | 15,770 ms |
コンパイル使用メモリ | 386,136 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 11:37:05 |
合計ジャッジ時間 | 12,435 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
use std::io::*; use std::str::FromStr; fn calc(n: i64, z: i64) -> String { let zpown = z.pow(n as u32); for x in 1..z { let xpown = x.pow(n as u32); let ypown = zpown - xpown; let y = (ypown as f64).sqrt() as i64; if y * y == ypown && xpown + ypown == zpown { return "Yes".to_string(); } } "No".to_string() } fn main() { let mut s = String::new(); stdin().read_line(&mut s).ok(); let mut it = s.split_whitespace(); let n = i64::from_str(it.next().unwrap()).unwrap(); let z = i64::from_str(it.next().unwrap()).unwrap(); if n >= 3 { println!("No"); } else { if z == 1 { println!("No"); } else { println!("{}", calc(n, z)); } } }