Scientific Problem(数学,简单)
来源:互联网 发布:康熙字典字体下载mac 编辑:程序博客网 时间:2024/05/16 17:36
Scientific Problem
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Once upon a time Professor Idioticideasinventor was travelling by train. Watching cheerless landscape outside the window, he decided to invent the theme of his new scientific work. All of a sudden a brilliant idea struck him: to develop an effective algorithm finding an integer number, which is x times less than the sum of all its integer positive predecessors, where numberx is given. As far as he has no computer in the train, you have to solve this difficult problem.
Input
The first line of the input file contains an integer number x (1 ≤ x ≤ 109).
Output
Output an integer number — the answer to the problem.
Sample Input
sample input
sample output
1
3
sample input
sample output
2
5
设答案为n,则nx < 1 +2 +3 + ... + n - 1 ,得到 n > 2x,所以n = 2x +1
AC CODE
//Memory: 935 KB Time: 31 MS//Language: GNU CPP (MinGW, GCC 4) Result: Accepted#include <iostream>#include <string>#include <cstdio>#include <cmath>#include <cstring>#include <algorithm>#define LL long long#define MAXI 2147483647#define MAXL 9223372036854775807#define eps (1e-8)#define dg(i) cout << "*" << i << endl;using namespace std;int main(){ LL x; while(scanf("%I64d", &x) != EOF) { printf("%I64d\n", 2 * x + 1); } return 0;}
- Scientific Problem(数学,简单)
- Scientific Problem
- SGU - 107 - 987654321 problem (简单数学!)
- How To Choose a Good Scientific Problem
- SGU - 403 - Scientific Problem (水)
- codeforce 798C Mike and gcd problem (简单数学)
- HDU 5974 A Simple Math Problem(简单数学)
- zoj2818 Root of the Problem 简单数学 开方
- FZU2108:Mod problem(数学)
- 简单数学
- An easy problem+数学推理
- hdu 5104 Primes Problem(数学)
- hdu 5105 Math Problem(数学)
- Problem 1603 - Minimum Sum 【数学】
- 5858 Hard problem (数学)
- 4.8胡策Problem 1 数学
- 最强数学库GSL(GNU Scientific Library) Qt环境下部署
- 简单数学程序
- 深入理解Flash Player的应用程序域(Application Domains)
- Win7下虚拟机个人使用小结:Virtual PC,VMware和VirtualBox
- 通过JS提交表单
- YUV格式详解
- wget 命令
- Scientific Problem(数学,简单)
- 2009, 基于git的备份系统
- 严重: Exception starting filter struts2
- vi中执行shell命令
- C++ 十分钟看指针
- 预分配mysql binlog文件存储空间有可能较大幅度提升性能
- Linux 制作ISO文件
- S5PV210 Android camera S_INPUT实现
- 10中排序算法总结