| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
0ms#include "iostream"
using namespace std;
bool isInterger(double num)
{
if(num-0.000001 < int(num))
return true;
else
return false;
}
int main()
{
int total;
int n = 2; //ÊýÁиöÊý
double a1; //ÊýÁÐÊ×Ïî
cin>>total;
while(total--)
{
int count =0;
int index;
cin>>index;
double num;
cin>>num;
n=2;
while(1)
{
if(n*(n-1)/2 >= num) //a1*n+n*(n-1)/2 ÓÐÒ»²¿·ÖÒѾ´óÓÚ¸ÃÊýÔòÌø³öÑ»·
break;
a1 = (num - n*(n-1)/2)/n;
if(isInterger(a1)) //¼ÙÈça1³ýÍêºóÊÇÕûÊý£¬Ôò¸ÃÁ¬Êý¿ÉÐÐ
{
count++;
}
n++;
}
cout<<index<<" "<<count<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator