http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1191
直接暴力,搞得我还防溢出,原来没有测试溢出的数据
代码如下:
#include <stdio.h>
#include <math.h>
int main()
{
int i;
int j;
int re = 0;
int a[100000];
bool b[100000];
int counter = 0;
while(scanf("%d", &a[counter]) != EOF)
{
b[counter] = true;
counter++;
}
for(i = 0; i < counter; i++)
{
for(j = 0; j < counter; j++)
{
if(a[i] * a[j] == 479001600 && sqrt(a[i]) * sqrt(a[j]) < 25000.0 && sqrt(a[i]) * sqrt(a[j]) > 20000.0 && b[i] && b[j])
{
b[i] = false;
b[j] = false;
re++;
}
}
}
printf("%d\n", re);
return 0;
}