标签:des style blog http io ar color os sp
思路:
假设答案为[i,j],则有:j2+j-i2-i=2M --> (j+i+1)(j-i)=2M
对2M进行分解,,然后判断,,搞一搞,,
代码:
int n,m; int main(){ while(cin>>n>>m,n||m){ m*=2; int t=(int)sqrt(m+0.5); rep2(i,t,1){ if(m%i==0){ int a,b; a=m/i, b=i; int x,y; x=(a-b-1)/2; y=(a+b-1)/2; if(x<0 || y>n || (2*x+1)!=(a-b) || (2*y+1)!=(a+b)) continue; printf("[%d,%d]\n",x+1,y); } } cout<<endl; } }
hdu 2058 The sum problem(简单因式分解,,)
标签:des style blog http io ar color os sp
原文地址:http://www.cnblogs.com/fish7/p/4138175.html