zoukankan      html  css  js  c++  java
  • Scientific Problem(数学,简单)

    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 number x 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;
    }
  • 相关阅读:
    C++ 整型长度的获取 不同的系统
    第二章习题 C++
    输入cin对象的用法
    将Mnist手写数字库转化为图片形式 和标签形式
    寻找图片中数字的轮廓并裁剪 扣取数字
    Linux中的日志功能
    Linux中的系统默认日志
    Linux中进程在前后台的切换
    Linux中的服务管理
    Linux中的流程控制语句
  • 原文地址:https://www.cnblogs.com/cszlg/p/2910473.html
Copyright © 2011-2022 走看看