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

12

Sample Output

7

Hint

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的更多相关文章

  1. POJ 1844 Sum【简单数学】

    链接: http://poj.org/problem?id=1844 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29256#probl ...

  2. POJ 1844 Sum

    题意:给一个整数n,求当n由1到k的连续整数加或减组成时的最小的k. 解法:一开始觉得dp……后来觉得复杂度太大了……GG……百度了一下是个数学题orz. 如果n全部由加法组成,那么k可以组成k(k+ ...

  3. ACM:POJ 2739 Sum of Consecutive Prime Numbers-素数打表-尺取法

    POJ 2739 Sum of Consecutive Prime Numbers Time Limit:1000MS     Memory Limit:65536KB     64bit IO Fo ...

  4. POJ.2739 Sum of Consecutive Prime Numbers(水)

    POJ.2739 Sum of Consecutive Prime Numbers(水) 代码总览 #include <cstdio> #include <cstring> # ...

  5. POJ 2739 Sum of Consecutive Prime Numbers(素数)

    POJ 2739 Sum of Consecutive Prime Numbers(素数) http://poj.org/problem? id=2739 题意: 给你一个10000以内的自然数X.然 ...

  6. POJ 1844:Sum ”滚动“数组

    Sum Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10494   Accepted: 6895 Description ...

  7. OpenJudge/Poj 2000 Gold Coins

    1.链接地址: http://bailian.openjudge.cn/practice/2000 http://poj.org/problem?id=2000 2.题目: 总Time Limit: ...

  8. OpenJudge/Poj 1915 Knight Moves

    1.链接地址: http://bailian.openjudge.cn/practice/1915 http://poj.org/problem?id=1915 2.题目: 总Time Limit: ...

  9. OpenJudge/Poj 1163 The Triangle

    1.链接地址: http://bailian.openjudge.cn/practice/1163 http://poj.org/problem?id=1163 2.题目: 总时间限制: 1000ms ...

随机推荐

  1. SQLite使用教程6 创建表

    http://www.runoob.com/sqlite/sqlite-create-table.html SQLite 创建表 SQLite 的 CREATE TABLE 语句用于在任何给定的数据库 ...

  2. 汽车行业的DMS系统 IT不变应万变

    DMS是针对4S店的整车销售.零配件仓库.售后维修服务(含车间管理).客服服务涵盖4S店业务进行完整管理的系统,是对销售.维修.客户关系进行一系列的整合.其中,服务的预约.进店接待都有着跟踪处理,客户 ...

  3. Cocos2d-x 3.x 资料整理

     cocos2d-x-3.0rc0新project的分辨率设置和控制台输出信息 http://kome2000.blog.51cto.com/969562/1379704 Cocos2d-x 3. ...

  4. hdu 1712 ACboy needs your help 分组背包

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...

  5. PAT 1013

    1013. Battle Over Cities (25) It is vitally important to have all the cities connected by highways i ...

  6. java_JdbcUtilis_单实例

    //eg1,没有使用单实例,eg2有 package cn.itcast; import java.sql.Connection; import java.sql.DriverManager; imp ...

  7. Java基础知识强化之多线程笔记03:进程与线程 和 多线程的意义

    1. 要想了解多线程,必须先了解线程,而要想了解线程,必须先了解进程,因为线程是依赖于进程而存在. 2. 什么是进程? 通过任务管理器我们就看到了进程的存在. 而通过观察,我们发现只有运行的程序才会出 ...

  8. Forwarding a Range of Ports in VirtualBox

    STAN SCHWERTLY MAY 9, 2012 ARTICLES 3 COMMENTS Doesn't allow forwarding a range of ports through the ...

  9. JavaScript学习总结一(String对象的用法)

    javascript String对象的常用API 1:indexOf indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置.如果没有找到匹配的字符串则返回 -1.注意: inde ...

  10. [转]Easy Stored Procedure Output Oracle Select

    本文转自:http://www.oraclealchemist.com/oracle/easy-stored-procedure-output/ I answered a question on a ...