?? 1017 a mathematical curiosity.cpp
字號:
/*
1017 A Mathematical Curiosity
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 5120 K
GUN C++
*/
/*Input & Sample Input
1(測試數(shù)據(jù)組的組數(shù))
10 1(每組測試數(shù)據(jù)中的一個,分別代表n,m)
20 3
30 4
0 0(每組測試數(shù)據(jù)由m=0,n=0結(jié)束)
Output & Sample Output
Case 1: 2(輸出對數(shù))
Case 2: 4
Case 3: 5
(測試數(shù)據(jù)組與組間有一空行)*/
#include<iostream>
using namespace std;
int main()
{
int a,b,i,j,count=0;
int c,n,m,v;
float d;
cin>>c;
for(i=0;i<c;i++)
{
for(j=1;;j++)
{
cin>>n>>m;
if(n==0&&m==0)
break;
for(b=1;b<n;b++)
for(a=1;a<b;a++)
{
v=(int)(a*a+b*b+m)/(a*b);
d=(float)(a*a+b*b+m)/(a*b);
if(d==v)
count++;
}//for a b
cout<<"Case"<<" "<<j<<":"<<" "<<count<<endl;
count=0;
}//for j
if(i!=c-1)
cout<<endl;
}
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -