結果

問題 No.152 貯金箱の消失
ユーザー obaoba
提出日時 2015-02-16 01:11:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 667 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 144,820 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 01:33:03
合計ジャッジ時間 1,909 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define rep(a,b) REP(a,0,b)
#define REPR(a,b,c) for(int a=b; a>(int)c; a++)
#define repr(a,b) REPR(a,b,0)
#define pb(a) push_back(a)
#define show(a) rep(iiixxxaaaa, a.size()) cout << a[i] << ", ";
typedef long long int ll;
using namespace std;

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

int main(){
  ll L;
  cin >> L;
  L /= 4;
  ll cnt = 0;

  for(int i=1;; i++){
	if((i*i) >= L) break;
	for(int j= (i%2==0) ? 1 : 2; j<i; j+=2){
	  if(gcd(i,j) == 1){
		ll sum = i*i-j*j + 2*i*j + i*i+j*j;
		if(sum > L) break;
		cnt++;
	  }
	}
  }
  cout << cnt%1000003 << endl;  
  return 0;
}
0