結果

問題 No.152 貯金箱の消失
ユーザー ぴろずぴろず
提出日時 2015-02-16 00:15:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 1,193 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 75,444 KB
実行使用メモリ 57,648 KB
最終ジャッジ日時 2023-09-06 01:30:54
合計ジャッジ時間 5,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,736 KB
testcase_01 AC 125 ms
55,316 KB
testcase_02 AC 127 ms
55,696 KB
testcase_03 AC 126 ms
55,840 KB
testcase_04 AC 129 ms
55,348 KB
testcase_05 AC 129 ms
55,468 KB
testcase_06 AC 133 ms
55,760 KB
testcase_07 AC 138 ms
55,540 KB
testcase_08 AC 159 ms
55,604 KB
testcase_09 AC 157 ms
55,352 KB
testcase_10 AC 153 ms
55,644 KB
testcase_11 AC 142 ms
57,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no152;

import java.util.Scanner;

// http://ja.wikipedia.org/wiki/%E3%83%94%E3%82%BF%E3%82%B4%E3%83%A9%E3%82%B9%E3%81%AE%E5%AE%9A%E7%90%86

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt() / 4;
		int ans = 0;
		for(long n=1;n<=l;n++) {
			for(long m=n+1;2*m*(n+m)<=l;m+=2) {
				if (gcd(n,m) == 1) {
					ans++;
				}
			}
		}
		System.out.println(ans % 1000003);
	}
	public static long gcd(long a,long b) {
		while(b!=0) {
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}


}
class Pair<A extends Comparable<A>,B extends Comparable<B>> implements Comparable<Pair<A,B>>{
	A a;
	B b;
	public Pair(A a,B b) {
		this.a = a;
		this.b = b;
	}
	public int compareTo(Pair<A, B> o) {
		int comp = a.compareTo(o.a);
		if (comp != 0) {
			return comp;
		}
		return b.compareTo(o.b);
	}
	public boolean equals(Object o) {
		if (o instanceof Pair) {
			@SuppressWarnings("rawtypes")
			Pair p = (Pair) o;
			return a.equals(p.a) && b.equals(p.b);
		}
		return super.equals(o);
	}
	public int hashCode() {
		return a.hashCode() + b.hashCode();
	}
	public String toString() {
		return "[" + a + "," + b + "]";
	}
}
0