SGU - 403 - Scientific Problem (水)
403. Scientific Problem
Memory limit: 65536 kilobytes
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.
The first line of the input file contains an integer number x (1 ≤ x ≤ 109).
Output an integer number — the answer to the problem.
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 (水)的更多相关文章
- SGU 403 Scientific Problem
403. Scientific Problem Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes input: stan ...
- 找规律 SGU 107 987654321 problem
题目地址:http://acm.sgu.ru/problem.php?contest=0&problem=107 /* 题意:n位数的平方的后面几位为987654321的个数 尼玛,我看描述这 ...
- SGU 107 987654321 problem【找规律】
题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=107 题意: 平方后几位为987654321的n位数有多少个 分析: 虽然说是水题 ...
- SGU 205. Quantization Problem
205. Quantization Problem time limit per test: 0.25 sec. memory limit per test: 65536 KB input: stan ...
- hdu-5867 Water problem(水题)
题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- Poj1207 The 3n + 1 problem(水题(数据)+陷阱)
一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...
- Codeforces - 1194B - Yet Another Crosses Problem - 水题
https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...
- CodeForces 706C Hard problem (水DP)
题意:对于给定的n个字符串,可以花费a[i] 将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...
- sgu 107 987654321 problem
其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 ...
随机推荐
- Java—将文件压缩为zip文件
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import ...
- 第二个Activity返回数据
背景内容:FirstActivity先跳转到TwoActivity,再由TwoActivity返回,并还返回数据. 一般情况下Activity间跳转只需要调用 startActivity(Intent ...
- unity3d 各键值对应代码
KeyCode :KeyCode是由Event.keyCode返回的.这些直接映射到键盘上的物理键. 值 对应键 Backspace 退格键 Delete Delet ...
- MonoBehaviour简述
Unity中的脚本都是继承自MonoBehaviour. 一.基础函数: 创建脚本就默认的update.start方法:(这些官方的文档都是有的) Start:Update函数第一次运行前调用,一般用 ...
- mysql常用命令介绍
mysql适用于在Internet上存取数据,支持多种平台 1.主键:唯一标识表中每行的这个列,没有主键更新或删除表中的特定行很困难. 2.连接mysql可以用Navicat 要读取数据库中的内容先要 ...
- windows 设置注册表服务自动启动
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\xxx\Start = ,=自动,,=禁用
- post发送 ArrayBuffer
// 用 POST 方法将 ArrayBuffer 发送到服务器 ); var longInt8View = new Uint8Array(myArray); ; i< longInt8View ...
- ES6 中set的用法
- demo记录
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http ...
- redis --------- 使用命令(每天一个)
Key(键) Del 语法:DEL Key [key ...] 删除给定的一个或者多个key 不存在的key会被忽略. 返回值: 被删粗key的数量# 删除单个 key redis ...