結果
問題 | No.152 貯金箱の消失 |
ユーザー |
![]() |
提出日時 | 2015-02-15 23:40:14 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,315 ms / 5,000 ms |
コード長 | 1,385 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 83,772 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 20:26:29 |
合計ジャッジ時間 | 5,568 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#define _USE_MATH_DEFINES#include <algorithm>#include <cstdio>#include <functional>#include <iostream>#include <cfloat>#include <climits>#include <cstring>#include <cmath>#include <map>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <time.h>#include <vector>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> i_i;typedef pair<ll, int> ll_i;typedef pair<double, int> d_i;typedef pair<ll, ll> ll_ll;typedef pair<double, double> d_d;struct edge { int u, v, w; };ll MOD = 1000000007;ll _MOD = 1000000009;double EPS = 1e-10;int INF = INT_MAX / 2;char c[100001];vector<int> manachar(string& S) {vector<int> R(S.length());int i = 0, j = 0;while (i < S.size()) {while(i-j >= 0 && i+j < S.size() && S[i-j] == S[i+j]) ++j;R[i] = j;int k = 1;while(i-k >= 0 && i+k < S.size() && k+R[i-k] < j) R[i+k] = R[i-k], ++k;i += k; j -= k;}return R;}ll gcd(ll a, ll b) {if (b == 0) return abs(a);else return gcd(b, a % b);}int main() {ll L; cin >> L;ll ans = 0;for (ll m = 1; m <= L; m++)for (ll n = 1; n < m && 2 * m * n < L; n++) {if ((m - n) % 2 == 0 || gcd(m, n) != 1) continue;ll a = m * m - n * n, b = 2 * m * n, c = m * m + n * n;ll x = (a + b + c) * 4;if (x <= L) ans = (ans + 1) % 1000003;}cout << ans << endl;}