Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u

[Submit]   [Go Back]   [Status]

Description

Daxia is so cute that people loves it so much.

Everyone wants to buy Daxia from Suneast (a business man who sells Daxia).

Suneast is a strange business man. He sells Daxia in a random price from 1, 2, 3, 4, 5…, n.

We now consider the price of Daxia is N $. If a custom has M $(M>=N) in hand and buy Daxia using Q $(N<=Q<=M), Suneast needs to return R=(Q-N) $ to the custom. Suneast is so a strange business man that he take the Q $, and he refuses to look for a change if the custom can’t show him R$ in his hand.

Now, we want to know how many pieces of money people should bring with to buy a Daxia with the exactly price. (The value of money can be any positive integers.)

Input

There are multiple test cases. Each test case has an integer n (1<=n<=254664467) in a single line.

Output

For each case, output a single integer in a line indicates the number of pieces of money people should bring with to buy a Daxia whose price is random from 1 to n.

Sample Input

1
2
5

Sample Output

1
2
3

Hint

In test case 1: people can bring 1 piece of money: 1$

In test case 2: people can bring 2 pieces of money:

In test case 3: people can bring 3 pieces of money:

呵呵,这题看师兄的才懂了!
 
 #include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n;
long long a[];
a[]=;
for(int i=;i<;i++)a[i]=a[i-]*+;
while(cin>>n)
{
for(int i=;i<;i++)
if(n<=a[i])
{
cout<<i<<endl;
break;
}
}
}

Suneast & Daxia (规律)的更多相关文章

  1. FZU 2240 Daxia & Suneast's problem

    博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...

  2. FZU Problem 2238 Daxia & Wzc's problem

    Daxia在2016年5月期间去瑞士度蜜月,顺便拜访了Wzc,Wzc给他出了一个问题: Wzc给Daxia等差数列A(0),告诉Daxia首项a和公差d; 首先让Daxia求出数列A(0)前n项和,得 ...

  3. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  4. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  5. ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)

    //POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...

  6. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  7. 在sqlserver中做fibonacci(斐波那契)规律运算

    --利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...

  8. 谈谈黑客攻防技术的成长规律(aullik5)

    黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...

  9. Math.abs(~2018),掌握规律即可!

    Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...

随机推荐

  1. selenium、python、firefox版本配合无敌

     selenium (2.53.6) .python2.7.13. firefox46.0.1 完美

  2. 慕课网视频破解付费分享-前端开发-Python等

    微信小程序 慕课网   BAT大牛经验总结全面深入解读Android面试   前端JS基础面试技巧   vue2.0+node.js+mongodb全栈打造商城   Vue.js高级实战-开发移动端音 ...

  3. Liunx-常用命令的总结(5)

    cd     ../dir        上一节目录下dir目录 cd -                    返回上次目录 ifconfig            查看IP地址 sudo   if ...

  4. IT经典书籍——Head First系列…

    Head First 系列书籍是由 O'Relly 出版社发行的一系列教育书籍,中文一般翻译为"深入浅出",它强调以特殊的方式排版,由大量的图片和有趣的内容组合构成,而达到非疲劳的 ...

  5. 自制VTP实验总结

    (packet tracer模拟器) 6.1)实验拓扑 //绿色:通:橙色:不通 //sw0是根桥:全通 Pc0:ip 192.168.1.1 Pc1: ip 192.168.1.2 Pc2:ip 1 ...

  6. Vue项目搭建基础之Vue-cli模版测试

    第一步安装node,nodejs.org下载node稳定版安装包.node -v   (查看node版本)npm install -g vue-cli(安装Vue脚手架环境)vuevue listvu ...

  7. 201521123050 《Java程序设计》第4周学习总结

    1. 本周学习总结 2. 书面作业 1.注释的应用 1.1使用类的注释与方法的注释为前面编写的类与方法进行注释,并在Eclipse中查看.(截图) 2.面向对象设计(大作业1,非常重要) 2.1 将在 ...

  8. 201521123078《Java程序设计》第2周学习总结

    1. 本周学习总结 **学会使用码云管理代码,包括将本地的代码上传至码云,和将码云上的项目保存至本地.编程要掌握重要的类名的使用,提高编程效率,避免想无头苍蝇一样** 2. 书面作业 使用Eclips ...

  9. 201521123110《Java程序设计》第1周学习总结

    1.第一周学习总结 `本周开始了对java的初次学习接触,Java是一门新的编程语言不同于C,由于有了c的基础,对于Java的理解和学习也相对从前学C更容易些. 也学习了Java的诞生发展以及运用包括 ...

  10. 201521123108《Java程序设计》第12周学习总结

    1. 本周学习总结 2. 书面作业 将Student对象(属性:int id, String name,int age,double grade)写入文件student.data.从文件读出显示. Q ...