結果

問題 No.152 貯金箱の消失
ユーザー hotpepsihotpepsi
提出日時 2015-09-22 00:50:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 61,088 KB
実行使用メモリ 7,468 KB
最終ジャッジ日時 2023-09-26 14:18:58
合計ジャッジ時間 7,374 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <cmath>

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	N /= 4;
	int ans = 0;
	for (int a = 3; a < N; ++a) {
		for (int b = a + 1; ; ++b) {
			if (gcd(a, b) != 1) {
				continue;
			}
			int d = a * a + b * b;
			int c = (int)sqrt(d);
			if (a + b + c > N) {
				break;
			}
			if (c * c == d) {
				++ans;
			}
		}
	}
	cout << (ans % 1000003) << endl;
	return 0;
}
0