hdu 2058
PS:TLE了N次...虽然结果对了...后来看了公式才知道要枚举项数才行...
代码:
#include "stdio.h"
#include "math.h"
int main(){
int i,j,k;
int n,m,s,t;
while(~scanf("%d%d",&n,&m) && (n || m)){
t=(int)sqrt(2.0*m);
for(;0<t;t--){
s=m-(t-1)*t/2;
if(s%t==0){
printf("[%d,%d]\n",s/t,s/t+(t-1));
}
}
puts("");
}
return 0;
}
hdu 2058的更多相关文章
- 题解报告:hdu 2058 The sum problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2058 问题描述 给定一个序列1,2,3,...... N,你的工作是计算所有可能的子序列,其子序列的总 ...
- HDU 2058 The sum problem
传送门 Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequen ...
- HDU 2058 The sum problem(枚举)
The sum problem Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the ...
- HDU 2058:The sum problem(数学)
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 2058 The sum problem (数学+暴力)
题意:给定一个N和M,N表示从1到N的连续序列,让你求在1到N这个序列中连续子序列的和为M的子序列区间. 析:很明显最直接的方法就是暴力,可是不幸的是,由于N,M太大了,肯定会TLE的.所以我们就想能 ...
- hdu 2058 The sum problem(数学题)
一个数学问题:copy了别人的博客 #include<cstdio> #include<cstdlib> #include<cmath> int main() { ...
- HDU 2058 The sum problem 数学题
解题报告:可以说是一个纯数学题,要用到二元一次和二元二次解方程,我们假设[a,b]这个区间的所有的数的和是N,由此,我们可以得到以下公式: (b-a+1)*(a+b) / 2 = N;很显然,这是一个 ...
- HDU - 2058 The sum problem(思路题)
题目: Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the ...
- hdu 2058 枚举区间和个数
题意: 给你两个数n,m,意思是有一个序列长度n,他是1 2 3 4 ...n,然后让你输出所有连续和等于m的范围. 思路: 是个小水题,随便写几个数字就能发现规律了,我们可以 ...
随机推荐
- const 不再迷茫
博客地址:http://blog.csdn.net/jiangxinnju github:https://github.com/jiangxincode 首先说明一下const在C和C++中的主要用法 ...
- Java开发Maven环境配置和介绍
最近很火热的12306的订票软件go-home,我也下载了一份下来了,使用了一下,也从svn中把代码down下来了,但是在eclipse中竟然出错了,依赖的jar包都没有找到,后来才知道人家是用mav ...
- php Composer 报ssl证书错误
CA证书下载地址:http://curl.haxx.se/docs/caextract.html 修改php.ini文件 openssl.cafile= D:/wamp/php/verify/cace ...
- Qt之Concurrent Map和Map-Reduce
简述 QtConcurrent::map().QtConcurrent::mapped()和QtConcurrent::mappedReduced()函数在一个序列中(例如:QList或QVector ...
- (31)odoo中的时间
* 在model中 from datetime import datetime, timedelta import time from openerp.tools impor ...
- python中文处理
源码文件为utf-8格式 CODEC = 'utf-8': VS在“高级保存选项”中选择“UTF-8 65001” input(u'中文');print(u'中文')
- HDFS使用0
创建上传文件的:
- c/c++----网站及其后门(CGI应用程序)
C/C++学习到这儿,结合自己曾经学过的javasweb知识,现在让我们来看看,如何做一个CGI程序吧! 首先了解一下啥子叫CGI :CGI全称是“公共网关接口”(Common Gateway In ...
- ABAP版连连看
网上看到的,感觉不错,借来装13... *&---------------------------------------------------------------------* *&a ...
- easyui datagrid 学习
一.清空datagrid所有数据 //得到所有数据行 var item = $('#ylProductListDataGrid').datagrid('getRows'); if (item) { / ...