OpenJudge/Poj 1844 Sum
1.链接地址:
http://bailian.openjudge.cn/practice/1844
http://poj.org/problem?id=1844
2.题目:
Sum
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10031 Accepted: 6564 Description
Consider the natural numbers from 1 to N. By associating to each number a sign (+ or -) and calculating the value of this expression we obtain a sum S. The problem is to determine for a given sum S the minimum number N for which we can obtain S by associating signs for all numbers between 1 to N.For a given S, find out the minimum value N in order to obtain S according to the conditions of the problem.
Input
The only line contains in the first line a positive integer S (0< S <= 100000) which represents the sum to be obtained.Output
The output will contain the minimum number N for which the sum S can be obtained.Sample Input
12Sample Output
7Hint
The sum 12 can be obtained from at least 7 terms in the following way: 12 = -1+2+3+4+5+6-7.Source
3.思路:
4.代码:
#include "stdio.h"
//#include "stdlib.h"
int main()
{
int m;
scanf("%d",&m);
int k = (int)((sqrt((float)()+*m)+)/);
while((k*k+k-*m)%!=)
{
k++;
}
printf("%d",k);
//system("pause");
return ;
}
OpenJudge/Poj 1844 Sum的更多相关文章
- POJ 1844 Sum【简单数学】
链接: http://poj.org/problem?id=1844 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29256#probl ...
- POJ 1844 Sum
题意:给一个整数n,求当n由1到k的连续整数加或减组成时的最小的k. 解法:一开始觉得dp……后来觉得复杂度太大了……GG……百度了一下是个数学题orz. 如果n全部由加法组成,那么k可以组成k(k+ ...
- ACM:POJ 2739 Sum of Consecutive Prime Numbers-素数打表-尺取法
POJ 2739 Sum of Consecutive Prime Numbers Time Limit:1000MS Memory Limit:65536KB 64bit IO Fo ...
- POJ.2739 Sum of Consecutive Prime Numbers(水)
POJ.2739 Sum of Consecutive Prime Numbers(水) 代码总览 #include <cstdio> #include <cstring> # ...
- POJ 2739 Sum of Consecutive Prime Numbers(素数)
POJ 2739 Sum of Consecutive Prime Numbers(素数) http://poj.org/problem? id=2739 题意: 给你一个10000以内的自然数X.然 ...
- POJ 1844:Sum ”滚动“数组
Sum Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10494 Accepted: 6895 Description ...
- OpenJudge/Poj 2000 Gold Coins
1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...
- OpenJudge/Poj 1915 Knight Moves
1.链接地址: http://bailian.openjudge.cn/practice/1915 http://poj.org/problem?id=1915 2.题目: 总Time Limit: ...
- OpenJudge/Poj 1163 The Triangle
1.链接地址: http://bailian.openjudge.cn/practice/1163 http://poj.org/problem?id=1163 2.题目: 总时间限制: 1000ms ...
随机推荐
- The Woman in Red Is Seen as a Threat by Other Wom
The Woman in Red Is Seen as a Threat by Other Wom In the 1939 film classic The Women, much is made o ...
- RefernceError : jQuery is not define
使用ligerUI 的时候,代码没有什么错误,可是不能正常显示组件 ,火狐debug显演示样例如以下错误: 最后发现是引入文件的顺序错了,最好依照ligerui demo中的顺序引入js文件,这样就不 ...
- 使用 Windows 窗体 TextBox 控件创建密码文本框
密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符. 创建密码文本框 将 TextBox 控件的 PasswordChar 属性设置为某个特定字符. PasswordChar 属 ...
- MyEclipse 10官网下载地址以及破解方法
刚刚公布了MyEclipse 10,我如今用的还是6.5的版本号,6.5的版本号是我认为最好用的一个版本号. 我装上了,还没感受到有哪些好用,就是感觉体积庞大,和IBM 的WID一样,是个多面手,啥事 ...
- [Effective C++ --018]让接口容易被正确使用,不易被误用
□第一节 什么是接口?什么是接口?百度百科的解释:两个不同系统(或子程序)交接并通过它彼此作用的部分.接口的概念贯穿于整个软件开发过程中,本文讨论的接口概念仅局限于以C++实现的class,funct ...
- Debug Certificate expired on 11-5-8 上午 6:26
好久没用电脑上的eclipse,今天新建了个安卓项目,发现报下面的错误: 后来得知: 是Debug证书过期所致. android应用必须经过签名证书进行数字签名后,才能安装,在开发调试阶段,默认情 ...
- [COCOS2DX]COCOS命令新建项目+编译安卓项目并成功运行
全程搭建过程参考网址: http://blog.csdn.net/lengxue789/article/details/38116475 http://blog.csdn.net/cbbbc/arti ...
- opencv里面CV_32FC1家族
因为总是接触过这样一些#define里面的东西但是总也不知道是干什么用的.而且每看一次梦比一次. 对于这些东西到底是什么的简写根本就不能理解. 原意是跑一下这个例程的: cvRectangle( my ...
- 记一次大量 TCP 连接失败
背景 在一段没有日志的历史遗留代码上面加入监控部署后不久,就收到了服务调用成功率低的告警,真是哗了狗了 解决过程 client端在线上单机部署,根据监控上面的返回码比例看出失败原因都是链接失败,通过 ...
- 【转载】Hadoop和大数据:60款顶级大数据开源工具
一.Hadoop相关工具 1. Hadoop Apache的Hadoop项目已几乎与大数据划上了等号.它不断壮大起来,已成为一个完整的生态系统,众多开源工具面向高度扩展的分布式计算. 支持的操作系统: ...