結果

問題 No.152 貯金箱の消失
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-28 02:07:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 173 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 74,156 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-10-25 21:55:05
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
57,712 KB
testcase_01 AC 120 ms
57,568 KB
testcase_02 AC 113 ms
57,232 KB
testcase_03 AC 116 ms
57,488 KB
testcase_04 AC 117 ms
57,444 KB
testcase_05 AC 118 ms
57,264 KB
testcase_06 AC 120 ms
57,288 KB
testcase_07 AC 132 ms
57,596 KB
testcase_08 AC 173 ms
57,688 KB
testcase_09 AC 170 ms
57,756 KB
testcase_10 AC 160 ms
57,184 KB
testcase_11 AC 145 ms
57,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long l = sc.nextLong();
    long ans = 0;
    long MOD = 1000003;
    for(long a = 2; (a * a * 8) < l; a++) {
      for(long b = 1; b < a; b++) {
        if((8 * a * a + 8 * a * b) <= l) {
          if((gcd(a, b) == 1) && (((a - b) % 2) == 1)) ans = (ans + 1) % MOD;
        }
      }
    }
    System.out.println(ans);
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}
0