QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726540#5676. Counting Pythagorean TriplesNika#Compile Error//C++14850b2024-11-09 02:31:142024-11-09 02:31:15

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 02:31:15]
  • 评测
  • [2024-11-09 02:31:14]
  • 提交

answer

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

using ll = long long;
void solve() {
  ll n; cin >> n;

  ll N = n*n;
  set<ll> cnt = {0};

  vector<int> A(4, 0);
  for (ll i = 1; i < ll(6250000+5); i++){
      ll I = i*i;
      ll J = max(N, I)-min(N, I);
      ll j = sqrtl(J);

      if (j*j != J || cnt.count(j)) continue;

      cnt.insert(i);
      cnt.insert(j);

      // cout << i << " " << j << " " << n << endl; 

      if (I+N == J || I+J == N || J+N == I){
        int PPT = (gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1);

        if (max({i, j, n}) == n) A[!PPT]++; 
        else A[(!PPT)+2]++;
      }
  }

  for (int i: A) cout << i << " ";
  cout << endl;
}

int main(){
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }
}

Details

answer.code: In function ‘void solve()’:
answer.code:26:20: error: ‘gcd’ was not declared in this scope
   26 |         int PPT = (gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1);
      |                    ^~~