作业帮 > 综合 > 作业

杭电acm1017题 感觉代码没错,但就是ac不了,我无解了,

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/18 21:58:06
杭电acm1017题 感觉代码没错,但就是ac不了,我无解了,
题目是这样的:Given two integers n and m,count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.
This problem contains multiple test cases!
The first line of a multiple input is an integer N,then a blank line followed by N input blocks.Each input block is in the format indicated in the problem description.There is a blank line between input blocks.
The output format consists of N output blocks.There is a blank line between output blocks.
InputYou will be given a number of cases in the input.Each case is specified by a line containing the integers n and m.The end of input is indicated by a case in which n = m = 0.You may assume that 0 < n
杭电acm1017题 感觉代码没错,但就是ac不了,我无解了,
/*不知道你为什么觉得你的代码没有问题,连测试样例都没过.
题目中是第一行输入有几组测试数据,这个组不是case,而是每个0 0标志一组结束
下面是根据你代码修改AC后的结果,
*/
#include
int main()
{
\x05int n,m,i,j,x,a,z=0,c;
\x05scanf("%d",&x);
\x05for(a=1;a1) printf("\n");
\x05\x05c = 0;
\x05\x05while(++c)
\x05\x05{
\x05\x05\x05scanf("%d %d",&n,&m);
\x05\x05\x05if(!((n==m)&&(n==0)))
\x05\x05\x05{
\x05\x05\x05\x05z=0;
\x05\x05\x05\x05for(i=1;i
再问: 其实我题目就不怎么懂,不明白已经用一个数来控制测试数量了为什么还要用0 0 控制测试结束
再答: 第一个数是控制测试数据组数的,每组以0 0做结尾。 例子给的是n=1的情况,如果n>1的话可以是这样: 2 20 3 30 4 0 0 10 1 40 5 60 8 0 0 n是控制0 0的个数,0 0是每一组的结束符。