結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-05-29 09:21:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 156 ms / 5,000 ms |
| コード長 | 1,487 bytes |
| コンパイル時間 | 725 ms |
| コンパイル使用メモリ | 88,980 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 10:33:04 |
| 合計ジャッジ時間 | 1,622 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#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 && g1 == g2 ) continue;
if (__gcd (m, n ) != 1LL ) continue;
// cerr << "m: " << m << " n: " << n << endl;
// cerr << m*m + n*n << ':' << 2*m*n << ':' << m*m - n*n << endl;
res = (res + 1 ) % MOD;
} // end for
} // end for
cout << res << endl;
return 0;
}
ty70