杭电ACM1017题,我的代码为什么总是Presentation Error
#include<iostream>usingnamespacestd;intmain(){intN,i,n,m,a,b,count,kase;while(cin>>N)...
#include<iostream>
using namespace std;
int main()
{
int N, i, n, m, a, b, count,kase;
while (cin>>N)
{
for (i = N; i > 0; i--)
{
kase=0;
while (cin >> n >> m)
{
count = 0;
kase++;
if (n == 0 && m == 0) break;
for (a = 1; a < n-1; a++)
for (b = a + 1; b < n; b++)
if ((a*a + b*b + m) % (a*b) == 0)
count++;
cout << "Case" << kase << ":" << count << endl;
}
if (i!=1) cout << endl;
}
}
return 0;
} 展开
using namespace std;
int main()
{
int N, i, n, m, a, b, count,kase;
while (cin>>N)
{
for (i = N; i > 0; i--)
{
kase=0;
while (cin >> n >> m)
{
count = 0;
kase++;
if (n == 0 && m == 0) break;
for (a = 1; a < n-1; a++)
for (b = a + 1; b < n; b++)
if ((a*a + b*b + m) % (a*b) == 0)
count++;
cout << "Case" << kase << ":" << count << endl;
}
if (i!=1) cout << endl;
}
}
return 0;
} 展开
1个回答
2017-02-03
展开全部
Case后面有空格
AC答案:
#include <bits/stdc++.h>
using namespace std;
int main()
{
// freopen("in.txt","r",stdin);
int n,m,t;
scanf("%d",&t);
while(t--)
{
int kcase=0;
while(scanf("%d%d",&n,&m)!=EOF && n!=0)
{
kcase++;
int a,b,dig=0;
for(a=1; a<n; a++)
for(b=a+1; b<n; b++)
{
double temp=(double)(a*a+b*b+m)/(a*b);
if((temp-(int)temp)==0)
dig++;
}
cout<<"Case "<<kcase<<": "<<dig<<endl;
}
if(t)
cout<<endl;
}
return 0;
}
AC答案:
#include <bits/stdc++.h>
using namespace std;
int main()
{
// freopen("in.txt","r",stdin);
int n,m,t;
scanf("%d",&t);
while(t--)
{
int kcase=0;
while(scanf("%d%d",&n,&m)!=EOF && n!=0)
{
kcase++;
int a,b,dig=0;
for(a=1; a<n; a++)
for(b=a+1; b<n; b++)
{
double temp=(double)(a*a+b*b+m)/(a*b);
if((temp-(int)temp)==0)
dig++;
}
cout<<"Case "<<kcase<<": "<<dig<<endl;
}
if(t)
cout<<endl;
}
return 0;
}
创远信科
2024-07-24 广告
2024-07-24 广告
作为上海创远仪器技术股份有限公司的团队成员,我们积累了广泛的介电常数数据。这些数据覆盖了从常见物质如空气、水、塑料到专业材料如聚苯乙烯、环乙醇等的介电常数。通过精心整理和分析,我们汇编了介电常数表合集,为客户提供了宝贵的参考信息。这些数据不...
点击进入详情页
本回答由创远信科提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询