結果

問題 No.152 貯金箱の消失
ユーザー furafura
提出日時 2020-05-12 01:35:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 199,076 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 19:09:40
合計ジャッジ時間 2,831 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int L; scanf("%d",&L);

	int ans=0;
	for(int m=2;4*m*m<=L;m++){
		for(int n=1;n<m;n++){
			int a=m*m-n*n;
			int b=2*m*n;
			int c=m*m+n*n;
			if(4*(a+b+c)>L) break;
			if(gcd(m,n)==1 && (m-n)%2==1){
				ans++;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}
0