結果

問題 No.2785 四乗足す四の末尾の0
ユーザー Yukino DX.Yukino DX.
提出日時 2024-06-15 17:30:08
言語 Rust
(1.77.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 13,307 ms
コンパイル使用メモリ 378,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-15 17:30:26
合計ジャッジ時間 16,236 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        t:usize,
        n:[i64;t],
    }

    for n in n {
        let a = n * n + 2 * n + 2;
        let b = n * n - 2 * n + 2;
        let is_p = a == 1 || b == 1;

        let mut cnt = [[0, 0], [0, 0]];
        for (i, mut x) in [a, b].into_iter().enumerate() {
            for (j, d) in [2, 5].into_iter().enumerate() {
                while x % d == 0 {
                    x /= d;
                    cnt[i][j] += 1;
                }
            }
        }

        let cnt2 = cnt[0][0] + cnt[1][0];
        let cnt5 = cnt[0][1] + cnt[1][1];
        let cnt10 = cnt2.min(cnt5);
        println!("{}", if is_p { "Yes" } else { "No" });
        println!("{}", cnt10);
    }
}
0