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 ...
随机推荐
- 文件控制列表命令setfacl和getfacl的使用
一 需求 有以下需求,通过setfacl命令实现 一组用户可写可读可执行,一组用户可写可执行,另一组用户只可读 linux rwx oracle wx uplook r 二 解决 第一步 添加六个用户 ...
- 【38】通过复合塑模出Has-A 或根据某物实现出
1.什么是复合? 复合是类型之间的一种关系,某种类型的对象内含其他类型的对象. 2.为什么需要复合,他解决什么问题? 为了代码复用. 3.复合有两层含义:Has-A和根据某物实现出.在应用域中,表示H ...
- jQuery操作select option
jQuery获取Select选择的Text和Value: 1. var checkText=jQuery("#select_id").find("option:selec ...
- 金蝶K3 破解版
- Android开发实例之多点触控程序
智能终端设备的多点触控操作为我们带来了种种炫酷体验,这也使得很多Android开发者都对多点触控程序的开发感兴趣.实际上多点触控程序的实现并不是那么遥不可及,而是比较容易.本文就主要通过一个实例具体讲 ...
- 基于Android 平台简易即时通讯的研究与设计[转]
摘要:论文简单介绍Android 平台的特性,主要阐述了基于Android 平台简易即时通讯(IM)的作用和功能以及实现方法.(复杂的通讯如引入视频音频等可以考虑AnyChat SDK~)关键词:An ...
- jquery插件开发(checkbox全选的简单实例)
html代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- 设计模式 - 命令模式(command pattern) 多命令 具体解释
命令模式(command pattern) 多命令 具体解释 本文地址: http://blog.csdn.net/caroline_wendy 參考命令模式: http://blog.csdn.ne ...
- Linux性能及调优指南(翻译)之Linux内存架构
http://blog.csdn.net/ljianhui/article/details/46734115
- JavaScript标准Selection操作
简介 术语 属性 方法 document.activeElement document.designMode = 'on'; 简介 selection是对当前激活选中区(即高亮文本)进行操作. 在非I ...