QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726539#5676. Counting Pythagorean TriplesNika#Compile Error//C++14776b2024-11-09 02:29:522024-11-09 02:29:52

Judging History

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

  • [2024-11-09 02:29:52]
  • 评测
  • [2024-11-09 02:29:52]
  • 提交

answer

#include <bits/stdc++.h>
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);

      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:23:20: error: ‘gcd’ was not declared in this scope
   23 |         int PPT = (gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1);
      |                    ^~~