結果

問題 No.152 貯金箱の消失
ユーザー edamame882edamame882
提出日時 2019-07-23 20:52:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 1,327 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 165,676 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 15:42:18
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//最大公約数

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll L;
  cin >> L;
  ll ans = 0;

  for(ll n = 1; n*(n+1) <= L; n++){
    for(ll m = n+1; 8*m*(m+n) <= L; m++){
      if(gcd((m*m - n*n) , gcd(2*n*m, m*m + n*n)) == 1){
        ans++;
      }
    }
  }
  // int i = 0;
  // while(8*(i+1)*(2*i+1) - L <= 0){
  //   i++;
  // }
  // cout << i << endl;
  cout << ans << endl;
  return 0;
}
0