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 ...
随机推荐
- Dubbo 分布式服务框架
要想了解Dubbo是什么,我们不防先了解它有什么用. 使用场景:比如我想开发一个网上商城项目,这个网上商城呢,比较复杂,分为pc端web管理后台,微信端销售公众号,那么我们分成四个项目,pc端网站,微 ...
- golang获取IP地址
ip:=this.Ctx.Request.RemoteAddr ip=ip[0:strings.LastIndex(ip, ":")]
- golang interface接口
package main import "fmt" type Shaper interface { Area() float32 } type Square struct { si ...
- 源码包的解压 .tar.gz /.tar.bz2的解压
解压方式如下: .tar.gz 格式解压为 tar -zxvf xx.tar.gz .tar.bz2 格式解压为 tar -jxvf ...
- phpStudy3——往数据库中添加数据
前言: 前边介绍了查询数据库的方法,这里介绍下往数据库中添加数据的方法. 项目需求: 用户在前端页面输入的用户名和手机号码,点击提交后后端判断手机号码是否已经存在.如果不存在,那么插入数据库到数据库, ...
- 【校招面试 之 C/C++】第15题 C 回调函数
转自:https://segmentfault.com/a/1190000008293902 做略微改动 什么是回调函数 我们先来看看百度百科是如何定义回调函数的: 回调函数就是一个通过函数指针调用的 ...
- 【校招面试 之 C/C++】第4题 拷贝构造函数被调用的3个时机
1.被调用的3个时机: (1)直接初始化或拷贝初始化: (2)将一个对象作为一个实参传递,形参采用非指针或非引用的对象进行接收时(指针即指向了同一块空间,并未实现拷贝:而引用就是实参本身): (3)函 ...
- Luogu 3959 [NOIP2017] 宝藏- 状压dp
题解 真的想不到这题状压的做法...听说还有跑的飞快的模拟退火,要是现场做绝对滚粗QAQ. 不考虑深度,先预处理出 $pt_{i, S}$ 表示让一个不属于 集合 $S$ 的 点$i$ 与点集 $S$ ...
- Laravel 中使用原生的 PHPExcel
1.安装 composer require maatwebsite/excel 之后,程序中就可以使用 PHPExcel 了 2.控制器中 public function export(Request ...
- [Selenium]验证点了某个Button之后无反应
期望:点了某个Button,无反应 问题:怎么去验证无反应 WebElement webElement = page.getICORemove(); SeleniumUtil.hover(page.g ...