結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2015-09-01 02:54:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 254 ms / 5,000 ms |
| コード長 | 930 bytes |
| コンパイル時間 | 2,347 ms |
| コンパイル使用メモリ | 79,240 KB |
| 実行使用メモリ | 41,560 KB |
| 最終ジャッジ日時 | 2024-07-18 17:18:54 |
| 合計ジャッジ時間 | 5,086 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Main {
public static long gcd(long a, long b){
return b == 0 ? a : gcd(b, a % b);
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
final long L = sc.nextLong();
int count = 0;
LOOP:
for(int m = 1; m < 10000; m++){
for(int n = m + 1; n < 10000; n++){
if(gcd(m, n) != 1){ continue;}
final int a = Math.abs(m * m - n * n);
final int b = 2 * m * n;
final int c = n * n + m * m;
if(gcd(a, gcd(b, c)) != 1){ continue; }
final long sum = (a + b + c) * 4l;
if(sum > L){
break;
}
//System.out.println(a + " " + b + " " + c);
count++;
}
}
System.out.println(count);
}
}
uafr_cs