結果

問題 No.152 貯金箱の消失
ユーザー ty70ty70
提出日時 2015-05-29 09:45:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 187 ms / 5,000 ms
コード長 1,386 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 86,364 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 15:30:04
合計ジャッジ時間 1,964 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MOD = (int)1e6 + 3;

int main()
{
	ios_base::sync_with_stdio(0);
	ll L; cin >> L;

	int res = 0;
	for (ll n = 1LL;n < L/4LL; n++ ){
		ll s = (ll)sqrt(16LL*n*n + 8LL*L );
		ll m8 = s - 4LL*n;
		if (m8 <= 0LL ) continue;
		for (ll m = m8/8LL; m >= n; m-- ){
			ll g1 = __gcd (m*m+n*n, 2LL*m*n );
			ll g2 = __gcd (2LL*m*n, m*m - n*n );
			if (g1 != 1LL && g2 != 1LL && __gcd (g1, g2 ) != 1LL  ) continue;
			if (__gcd (m, n ) != 1LL ) continue;
			res = (res + 1 ) % MOD;
		} // end for
	} // end for
	cout << res << endl;

	return 0;
}
0