結果

問題 No.152 貯金箱の消失
ユーザー ldsybldsyb
提出日時 2016-06-17 19:16:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 65,184 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 12:55:44
合計ジャッジ時間 1,065 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 6 ms
6,944 KB
testcase_08 AC 39 ms
6,940 KB
testcase_09 AC 39 ms
6,940 KB
testcase_10 AC 30 ms
6,940 KB
testcase_11 AC 17 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int gcd(int m,int n){
	if(m < n) swap(m,n);
	while(n){
		int tmp = n;
		n = m % n;
		m = tmp;
	}
	return m;
}

int main(){
	int ans = 0,l;
	cin >> l;
	l /= 4;
	for(int m = 1;m * m <= l;m++){
		for(int n = 1;n < m;n++){
			if((m - n) % 2 == 0 || gcd(m,n) != 1) continue;
			if(m * m - n * n + 2 * m * n + m * m + n * n <= l) ans++;
		}
	}
	cout << ans << endl;
}
0