hdu 2058 The sum problem
#include<stdio.h>
int main()
{
int i,m,x,y,n,ans,num;
while(~scanf("%d%d",&n,&m)&&n&&m)
{
ans=0;
for(i=1; i<n; i++)
{
ans+=i;
y=i;
if(ans>=m) break;
}
if(ans==m) num=i;
else num=i-1;
for(i=num; i>0; i--)
{
x=(2*m/i-(i-1))/2;
y=(2*m/i+(i-1))/2;
if((x+y)*(y-x+1)==2*m)
printf("[%d,%d]\n",x,y);
}
printf("\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/