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 内 ...
随机推荐
- IIS: 响应消息的内容类型 text/html; charset=utf-8 与绑定(text/xml; charset=utf-8)的内容类型不匹配。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法
以前好好的项目,突然出现了这个问题.一顿google后无果,有人说是程序池的原因,有人说是安全配置的原因,照着网上方法试了多次,还是没有解决.如下图: 突然发现了一片文章 (https://www.j ...
- JQuery:常用知识点总结
jQuery本质上就是一个外部的js文件(jQuery.js),该文件中封装了很多js代码,实现了很多功能.并且jQuery有非常丰富的插件,大多数功能都有相应的插件解决方案.jQuery的宗旨是wr ...
- WinForms_ListView中获取选中项数据值
string value = listList.SelectedItems[0].SubItems[1].Text;//获取首行listview的值 string va = listList.Sele ...
- Quartz中时间参数说明 即Cron表达式
Cron表达式 Quartz使用类似于Linux下的Cron表达式定义时间规则,Cron表达式由6或7个由空格分隔的时间字段组成,如表1所示: 表1 Cron表达式时间字段 位置 时间域名 允许值 允 ...
- html5——语义标签
传统布局 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF- ...
- HDU_2203_KMP入门
亲和串 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Python之模块、正则
一.模块import 模块的实质就是把要导入模块里面的代码,从上到下执行一遍,找模块的顺序是,先从当前目录下找,找不到的话,再环境变量里面找导入的模块名字最好不要有.,a.import sysprin ...
- VBA/VBScript提取Word(*.doc)文件中包含的图片(照片)
VBA/VBScript提取Word(*.doc)文件中包含的图片(照片) 要处理的人事简历表是典型的Word文档,其中一人一份doc,里面包含有个人的照片,如果要把里面的照片复制出来就比较麻烦了 ...
- Python 之糗事百科多线程爬虫案例
import requests from lxml import etree import json import threading import queue # 采集html类 class Get ...
- MongoDB主库和从库的数据大小不一致原因判断
1. 环境(MongoDB的版本是3.2.16) [root@xxx-mongodb-primary ~]# cat /etc/redhat-release CentOS Linux release ...