设为首页 加入收藏

TOP

hdu 2058 The sum problem(数学题)
2015-11-21 01:01:01 来源: 作者: 【 】 浏览:1
Tags:hdu 2058 The sum problem 数学题

题意:求[1,n]的子区间,使得子区间的元素和为m

\

?

?

代码:

?

#include
  
   
#include
   
     #include
    
      using namespace std; int main() { int n,m; while(scanf("%d%d",&n,&m)&&(n||m)) { for(int j=(int)sqrt(2*m);j>=1;j--) { int i=(2*m/j-j+1)/2; if((i*2-1+j)*j==2*m&&i+j-1<=n) { printf("[%d,%d]\n",i,i+j-1); } } printf("\n"); } return 0; } 
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj1436 Horizontally Visible Se.. 下一篇poj2976--Dropping tests(0-1分..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: