結果

問題 No.152 貯金箱の消失
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-14 08:29:03
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 25,448 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 15:30:59
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 22 ms
4,376 KB
testcase_09 AC 23 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int gcd( int a, int b){
	if(b == 0){
		return a;
	}
	
	if(a > b){
		return gcd(b,a%b);
	}else{
		return gcd(a,b%a);
	}
}

int main(void){
	int cnt=0;
	int L,m,n;
	
	scanf("%d", &L);
	
	L = L / 4;
	
	for(n=1;n<3000;n++){
		for(m=n+1;m<3000;m++){
			int a,b,c;
			int g = gcd(n,m);
			if((m-n)%2==0){continue;}
			if( g != 1){continue;}
			
			a = (m*m-n*n);
			b = (2*m*n);
			c = (m*m+n*n);
			if(a+b+c <= L){
				cnt = (cnt+1) % 1000003;
			}else{
				break;
			}
		}
	}
	
	printf("%d\n", cnt);
	return 0;
}
0