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 ...
随机推荐
-
无法将匿名方法转换为System.Delegate
在WinForm中,不允许非UI线程访问UI,如果非UI线程需要跨线程调用UI控件,通常的解决办法是使用Control类中的Invoke方法,传递给该方法一个委托和委托调用的参数列表(params [ ...
-
SOS 调试扩展 (SOS.dll) 《第五篇》
一.SOS扩展命令 SOS包含几十个命令,要熟练使用SOS,首先要了解SOS有哪些命令.下面给出SOS命令列表. 命令 描述 BPMD [<module name> <method ...
-
Sql 行转列、列转行及分页
说明:本实例是以 SQL Server 2005 为运行环境的. 准备工作:创建一个名为 DB 的数据库(CREATE DATABASE DB). 一.T-SQL 行转列 1.创建如下表 CREATE ...
-
JSP合用html5 尝试(一)
直接上代码 <%@page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %> ...
-
两款【linux字符界面下】显示【菜单】,【选项】的powershell脚本模块介绍
两款[linux字符界面下]显示[菜单],[选项]的powershell脚本模块介绍 powershell linux ps1 menu choice Multiselect 传教士 菜单 powe ...
-
日志组件一:Log4j
log4j是Apache的一个开源项目,陪伴了我们多年,但是现在已经不更新了.官网原文如下: Log4j 1.x has been widely adopted and used in many ap ...
-
简单excel导入导出
import java.io.File;import java.io.IOException; import jxl.Cell;import jxl.Sheet;import jxl.Workbook ...
-
HDFS Lease Recovey 和 Block Recovery
这篇分析一下Lease Recovery 和 Block Recovery hdfs支持hflush后,需要保证hflush的数据被读到,datanode重启不能简单的丢弃文件的最后一个block,而 ...
-
yocto-sumo源码解析(一): oe-init-build-env
oe-init-build-env是yocto构建环境运行的第一个脚本,通过运行下面的命令: . oe-init-build-env build-arm64 即可对yocto项目进行构建,顾名思义,该 ...
-
git编译安装报错 http-push.c:20:19: 警告:expat.h:没有那个文件或目录
解决: [root@hdoop3 git-2.18.1]# yum install expat-devel