結果

問題 No.152 貯金箱の消失
ユーザー hotpepsi
提出日時 2015-09-22 00:50:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 60,664 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-19 08:33:15
合計ジャッジ時間 7,132 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

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