結果

問題 No.1218 Something Like a Theorem
ユーザー どららどらら
提出日時 2020-09-21 15:36:53
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 138,396 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-06 17:09:12
合計ジャッジ時間 1,519 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;

        if 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));
        }
    }
}
0