首页 > 其他 > 详细

ZJNU 1129 - The sum problem——中级

时间:2020-01-19 13:30:43      阅读:53      评论:0      收藏:0      [点我收藏+]

枚举区间可能的长度len,将m减去1~len构成的序列和后如果结果是len的倍数,则可以构成答案区间。

 1 /*
 2 Written By. StelaYuri
 3 */
 4 #include<stdio.h>
 5 #include<math.h>
 6 int main(){
 7     int n,m,len,b;
 8     while(scanf("%d%d",&n,&m)!=EOF&&(n||m)){
 9         for(len=sqrt(m*2);len;len--){
10                 b=m-(len*len+len)/2;
11                 if(b%len==0)
12                     printf("[%d,%d]\n",(b/len)+1,(b/len)+len);
13         }
14         putchar(\n);
15     }
16     return 0;
17 }

ZJNU 1129 - The sum problem——中级

原文:https://www.cnblogs.com/stelayuri/p/12213253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!