結果

問題 No.152 貯金箱の消失
ユーザー GrenacheGrenache
提出日時 2016-02-13 01:17:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 322 ms / 5,000 ms
コード長 658 bytes
コンパイル時間 3,399 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 57,696 KB
最終ジャッジ日時 2023-10-22 04:01:12
合計ジャッジ時間 5,859 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
57,504 KB
testcase_01 AC 118 ms
57,448 KB
testcase_02 AC 117 ms
57,612 KB
testcase_03 AC 117 ms
57,484 KB
testcase_04 AC 108 ms
56,176 KB
testcase_05 AC 108 ms
56,224 KB
testcase_06 AC 123 ms
57,508 KB
testcase_07 AC 150 ms
57,340 KB
testcase_08 AC 316 ms
57,472 KB
testcase_09 AC 322 ms
57,696 KB
testcase_10 AC 272 ms
57,560 KB
testcase_11 AC 206 ms
57,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder152 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int l = sc.nextInt();

        int ret = 0;
        for (int n = 1; n * n < l; n++) {
        	for (int m = n + 1; m * m < l; m += 2) {
        		if (gcd(n, m) != 1) {
        			continue;
        		}

        		int tmp = m * (m + n) * 2;
        		if (tmp * 4 <= l) {
        			ret ++;
        		}
        	}
        }

        System.out.println(ret);

        sc.close();
    }

	private static int gcd(int n, int m) {
		if (m == 0) {
			return n;
		} else {
			return gcd(m, n % m);
		}
	}
}
0