QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100225#5676. Counting Pythagorean TriplesNicolas125841Compile Error//C++14867b2023-04-25 01:08:152023-04-25 01:12:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-25 01:12:17]
  • 评测
  • [2023-04-25 01:08:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll n;

    cin >> n;

    int one = 0, two = 0, three = 0, four = 0;

    for(ll i = 1; i < n; i++){
        for(ll j = i; j < n; j++){
            if(i*i + j*j == n*n){
                if(gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1)
                    one++;
                else
                    two++;
            }
        }
    }

    ll v = 1;

    while(2*v + 1 <= n*n){
        //cout << v << "\n";

        if((ll)pow((ll)sqrt(v*v+n*n), 2) == v*v+n*n){
            if(gcd(v, n) == 1 && gcd((ll)sqrt(v*v+n*n), n) == 1 && gcd((ll)sqrt(v*v+n*n), v) == 1)
                three++;
            else
                four++;
        }

        v++;
    }

    cout << one << " " << two << " " << three << " " << four << "\n";
}

Details

answer.code: In function ‘int main()’:
answer.code:17:20: error: ‘gcd’ was not declared in this scope
   17 |                 if(gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1)
      |                    ^~~
answer.code:31:16: error: ‘gcd’ was not declared in this scope
   31 |             if(gcd(v, n) == 1 && gcd((ll)sqrt(v*v+n*n), n) == 1 && gcd((ll)sqrt(v*v+n*n), v) == 1)
      |                ^~~