403. Scientific Problem

Time limit per test: 0.25 second(s)

Memory limit: 65536 kilobytes
input: standard

output: standard

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.

Example(s)
sample input
sample output
1
3
sample input
sample output
2
5


Online Contester Team © 2002 - 2010. All rights reserved.

思路:先给出一个数x。求出数n,使得n是n之前全部数(不包含n)的总和的1/x

由求和公式n*(n-1)/2/x = n 可得 n=2*x+1



AC代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int main() {
int x;
while(scanf("%d", &x) != EOF) {
printf("%d\n", 2*x+1);
}
return 0;
}

SGU - 403 - Scientific Problem (水)的更多相关文章

  1. SGU 403 Scientific Problem

    403. Scientific Problem Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes input: stan ...

  2. 找规律 SGU 107 987654321 problem

    题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这 ...

  3. SGU 107 987654321 problem【找规律】

    题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=107 题意: 平方后几位为987654321的n位数有多少个 分析: 虽然说是水题 ...

  4. SGU 205. Quantization Problem

    205. Quantization Problem time limit per test: 0.25 sec. memory limit per test: 65536 KB input: stan ...

  5. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  6. Poj1207 The 3n + 1 problem(水题(数据)+陷阱)

    一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...

  7. Codeforces - 1194B - Yet Another Crosses Problem - 水题

    https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...

  8. CodeForces 706C Hard problem (水DP)

    题意:对于给定的n个字符串,可以花费a[i]  将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...

  9. sgu 107 987654321 problem

    其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 ...

随机推荐

  1. EasyUI系列学习(一)-入门

    1.什么是jQuery EasyUI jQueryEasyUI是一组基于jQuery的UI插件集合 2.jQueryEasyUI的特点 可以通过html标记来定义用户界面:支持扩展,可根据最近的需求扩 ...

  2. PHP流程控制语句(if,foreach,break......)

    背景:PHP程序中,必不可少的要用到流程控制语句.这次对于流程控制语句进行一些总结. 条件控制语句和循环控制语句是两种基本的语法结构,它们都是用来控制程序执行流程.也是构成程序的主要语法基础. 一.程 ...

  3. Paint、Canvas

    1.Canvas类 public class Canvas { public static final int ALL_SAVE_FLAG = 31; /** @deprecated */ @Depr ...

  4. MonoBehaviour简述

    Unity中的脚本都是继承自MonoBehaviour. 一.基础函数: 创建脚本就默认的update.start方法:(这些官方的文档都是有的) Start:Update函数第一次运行前调用,一般用 ...

  5. windows远程桌面连接

    服务器端: 1.我的电脑->管理->本地用户和组->用户->新建用户设置账号密码,隶属于administrator和remote user 2.我的电脑->属性-> ...

  6. log4j最全教程

    (转自http://www.codeceo.com/article/log4j-usage.html) 日志是应用软件中不可缺少的部分,Apache的开源项目log4j是一个功能强大的日志组件,提供方 ...

  7. Codeforces_718A

    A. Efim and Strange Grade time limit per test 1 second memory limit per test 256 megabytes input sta ...

  8. apache配置多域名二级域名

    nginx配置多域名泛解析的看这个链接:https://www.cnblogs.com/Crazy-Liu/p/10879740.html 下面直接来操作: [root@localhost ~]# f ...

  9. 移动端rem布局 js

    // rem布局适配 (function(doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in ...

  10. 安装部署NetBeans mysql Tomact joget workflow 环境

    一.安装joget workflow 1.安装jdk 下载jdk http://www.oracle.com/technetwork/java/javase/downloads/index.html ...