没有链接
描述:
给p,q,求a^2+b^2 = p*q解的个数,p,q是素数沙雕打表结论题
然后怼了3h吼爆零
题解
首先这是个结论题
然后这是证明
代码
#include <stdio.h>
#include <algorithm>
using namespace std;
int p , q;
int ans;
void work () {
scanf ( "%d%d" , &p , &q );
if ( p > q ) swap ( p , q );
if ( p == q ) {
if ( p == 2 ) ans = 4;
if ( p % 4 == 1 ) ans = 12;
if ( p % 4 == 3 ) ans = 4;
}
else {
if ( p % 4 == 3 || q % 4 == 3 ) {
ans = 0;
}
else {
if ( p == 2 ) ans = 8;
else ans = 16;
}
}
printf ( "%d\n" , ans );
}
int main () {
freopen ( "prime.in" , "r" , stdin );
freopen ( "prime.out" , "w" , stdout );
int t;
scanf ( "%d" , &t );
while ( t-- ) work ();
return 0;
}