1153. Supercomputer

Time limit: 2.0 second
Memory limit: 64 MB
To check the speed of JCN Corporation new supercomputer it was decided to figure out the sum of first N (N < 10600) positive integers. Unfortunately, by the time the calculation was finished the Chief Programmer forgot the value of N he entered. Your task is to write the program (for personal computer), which would determine the value of N by the result calculated on supercomputer.
Note: JCN Corporation manufactures only reliable computers, and its programmers write only correctly working programs.

Input

One line containing the result of calculations on the supercomputer.

Output

Выведите N, the number entered by Chief Programmer.

Sample

input output
28
7
Problem Author: Eugene Bryzgalov 
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, English Round 
Difficulty: 314
 
题意:给出一个数,这个数是1+2+3+。。。+n的结果,问n
分析:显然输入的数等于n*(n+1)/2
解出这个数就行,直接求根也好,二分也罢,写好高精度就好
然而我用python,不用写高精。。。
(python的math库大数开根貌似会错)
 
 import math

 a = input()
a = a*2 left = 1
right = a
while(left <= right) :
mid = (left+right)/2
k = mid*(mid+1)
if k == a :
print mid
break
elif k > a :
right = mid-1
else :
left = mid+1

ural 1153. Supercomputer的更多相关文章

  1. URAL - 1153 Supercomputer 大数开方

    题意:给定m,m = n * (n+1) / 2,计算n值. 思路:n = SQRT(m*2) 注意m很大,需要自己实现大数开方.我用的是自己写的大数模板:大数模板 AC代码 #include < ...

  2. centos mysql 大量数据导入时1153 错误:1153 - Got a packet bigger than 'max_allowed_packet' bytes

    参考:http://stackoverflow.com/questions/93128/mysql-error-1153-got-a-packet-bigger-than-max-allowed-pa ...

  3. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  4. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  5. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  6. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  7. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  8. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  9. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

随机推荐

  1. stringbuffer 和 stringbuilder的区别

    1. stringbuffer 和 stringbuilder的区别 StringBuffer是线程安全的, 这个类里的所有方法是同步的.这个反过来就会对程序的性能有一定的影响.StringBuild ...

  2. RemObjects SDK Source For Delphi XE7

    原文:http://blog.csdn.net/tht2009/article/details/39545545 1.目前官网最新版本是RemObjects SDK for Delphi and al ...

  3. linux 下如何查看和踢除正在登陆的其它用户 ==>Linux下用于查看系统当前登录用户信息的4种方法

    在linux系统中用pkill命令踢出在线登录用户 由于linux服务器允许多用户登录,公司很多人知道密码,工作造成一定的障碍 所以需要有时踢出指定的用户 1/#who   查出当前有那些终端登录(用 ...

  4. MVC3和MVC4相关问题

    从TFS获取的MVC项目生成一直提示这个错误,我的VS中MVC3和MVC4都有,TFS项目中的MVC版本应该是MVC3的,现在我要用这个项目,但是一直是这个错误,请高手指点,积分不多了,见谅 程序集“ ...

  5. Unique Binary Search Trees I & II

    Given n, how many structurally unique BSTs (binary search trees) that store values 1...n? Example Gi ...

  6. 新建myeclipse工作空间需要的工作

    接触了许多个项目,都挺大的,每次都需要配置,简单总结总结. 第一.右击项目,选择Text file encoding 第二.点击window-->preferences-->myeclip ...

  7. 10件在PHP 7中不要做的事情

    刚刚在园子里看到一篇特别好的文章,就拿到我的园子里分享了. 1. 不要使用mysql_函数 这一天终于来了,从此你不仅仅“不应该”使用mysql_函数.PHP 7 已经把它们从核心中全部移除了,也就是 ...

  8. July 17th, Week 30th Sunday, 2016

    You are beautiful, but that is not why I love you. 你如此美丽,但我并非因此而爱你. Although we have always been tol ...

  9. Android UI组件

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  10. JAVA开发第一步——JDK 安装

    JDK,Java Development Kit. And JRE ,Java Runtime Environment. jdk分64位和32位,可自行去Oracle官网下载 直接百度下载链接 Win ...