hdu 2058 The sum problem(数学题)
一个数学问题:copy了别人的博客
#include<cstdio>
#include<cstdlib>
#include<cmath>
int main()
{
int n,m,i,j;
while(~scanf("%d%d",&n,&m))
{
for( j=(int)sqrt(2*m); j>=1;j--)
{
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;
}
hdu 2058 The sum problem(数学题)的更多相关文章
- HDU 2058 The sum problem 数学题
解题报告:可以说是一个纯数学题,要用到二元一次和二元二次解方程,我们假设[a,b]这个区间的所有的数的和是N,由此,我们可以得到以下公式: (b-a+1)*(a+b) / 2 = N;很显然,这是一个 ...
- 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
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2058 问题描述 给定一个序列1,2,3,...... N,你的工作是计算所有可能的子序列,其子序列的总 ...
- hdu 2058 The sum problem(简单因式分解,,)
Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-se ...
- 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(思路题)
题目: Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the ...
- HDU 2058 The sum problem (数学+暴力)
题意:给定一个N和M,N表示从1到N的连续序列,让你求在1到N这个序列中连续子序列的和为M的子序列区间. 析:很明显最直接的方法就是暴力,可是不幸的是,由于N,M太大了,肯定会TLE的.所以我们就想能 ...
- hdu 4961 Boring Sum(数学题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4961 Problem Description Number theory is interesting ...
- HDOJ 2058 The sum problem
Problem Description Given a sequence 1,2,3,--N, your job is to calculate all the possible sub-sequen ...
随机推荐
- 注册驱动MySQL的驱动程序
1.将驱动程序文件添加到应用项目 将驱动程序mysql-connector-Java-5.1.6-bin,复制到web应用程序的web-INF\lib下,web应用程序就可以通过JDBC接口访问MyS ...
- 梯度下降法】三:学习率衰减因子(decay)的原理与Python
http://www.41443.com/HTML/Python/20161027/512492.html
- SQL 变量、 运算符、 if 、while
变量: SQL语言也跟其他编程语言一样,拥有变量.分支.循环等控制语句. 在SQL语言里面把变量分为局部变量和全局变量,全局变量又称系统变量. 局部变量: 使用declare关键字给变量声明,语法非常 ...
- Anaconda中python加入环境变量
1.我的电脑---高级系统设置 2.选中环境变量,保存. 3.在系统环境变量PATH中,加入Anaconda3及Script路径加入其中 4.测试python
- DFT
离散傅里叶变换(Discrete Fourier Transform,缩写为DFT),是傅里叶变换在时域和频域上都呈离散的形式, 将信号的时域采样变换为其DTFT的频域采样.在形式上,变换两端(时域和 ...
- 6.ZigZag Conversion(Graph, traverse)
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...
- [leetcode]347. Top K Frequent Elements 最高频的前K个元素
Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2 ...
- 如何利用jQuery post传递含特殊字符的数据【转】
在jQuery中,我们通常利用$.ajax或$.post进行数据传递处理,但这里通常不能传递特殊字符,如:“<”.本文就介绍如何传递这种含特殊字符的数据. 1.准备页面和控制端代码 页面代码如下 ...
- silverlight的Datagrid控件列绑定属性笔记
<data:DataGridTemplateColumn Header="给作者留言"> <data:DataGridTemplateColumn.CellTem ...
- PHP-GTK的demo在windows下运行出现的问题
I am trying to use Firebird 2.5.2.26539 with wamp,When i enable the extensions of firebird in php: - ...