Suneast & Daxia (规律)
| Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
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
Output
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 (规律)的更多相关文章
- FZU 2240 Daxia & Suneast's problem
博弈,$SG$函数,规律,线段树. 这个问题套路很明显,先找求出$SG$函数值是多少,然后异或起来,如果是$0$就后手赢,否则先手赢.修改操作和区间查询的话可以用线段树维护一下区间异或和. 数据那么大 ...
- FZU Problem 2238 Daxia & Wzc's problem
Daxia在2016年5月期间去瑞士度蜜月,顺便拜访了Wzc,Wzc给他出了一个问题: Wzc给Daxia等差数列A(0),告诉Daxia首项a和公差d; 首先让Daxia求出数列A(0)前n项和,得 ...
- hdu1452 Happy 2004(规律+因子和+积性函数)
Happy 2004 题意:s为2004^x的因子和,求s%29. (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...
- 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 ...
- ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)
//POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- 在sqlserver中做fibonacci(斐波那契)规律运算
--利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...
- 谈谈黑客攻防技术的成长规律(aullik5)
黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...
- Math.abs(~2018),掌握规律即可!
Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...
随机推荐
- 学习Java第一天,大致了解
第一章: java核心 1 了解 java的产生背景 2 了解java的体系结构和组成 3 了解java程序的编写 编译 运行 4 掌握java的 api文档的使用 5 了解 jdk的组成 1. ja ...
- window的设置属性
1.windowAnimationStyle 用于设置一组window动画的引用style资源,window的动画属性由R.styleable.WindowAnimation定义. Winow动画类属 ...
- Ubuntu 14.04 安装LNMP(nginx/1.12.1+php7.1.9+mysql5.7.19)环境
这篇教程中,我们将讨论怎样在Ubuntu 14.04搭建LNMP环境 1 安装Nginx 首先我们要更新apt源 sudo add-apt-repository ppa:nginx/stable s ...
- Android WebView基本使用
转载请注明出处: http://blog.csdn.net/lowprofile_coding/article/details/77928614 WebView介绍 Android WebView在A ...
- 微信iOS收款到账语音提醒开发总结
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:https://mp.weixin.qq.com/s/yYCaPMxHGT9LyRyAPewVWQ 作者:l ...
- chrome开发工具指南(八)
编辑 DOM Chrome DevTools 的 Elements 面板中的 DOM 树视图可以显示当前网页的 DOM 结构.通过 DOM 更新实时修改页面的内容和结构. DOM 定义您的页面结构.每 ...
- css 弹性盒兼容性写法,直接复制粘贴
看这个定义弹性布局盒子display:-webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; disp ...
- WCF(二)三种通信模式
WCF在通信过程中有三种模式:请求与答复.单向.双工通信 请求与答复模式 客户端发送请求,然后一直等待服务端的响应答复(异步调用除外),期间处于假死状态,直到服务端有了答复后才能继续执行其他程序 请求 ...
- 英语学习app案列分析
很多同学有误解,软件工程课是否就是理论课?或者是几个牛人拼命写代码,其他人打酱油的课?要不然就是学习一个程序语言,搞一个职业培训的课?都不对,软件工程有理论,有实践,更重要的是分析,思辨,总结.在课程 ...
- 201521123026 《Java程序设计》第6周学习总结
1. 本章学习总结 请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结 2. 书面作业 Q1.clone方法 1.1 Object对象中的clone方法是被prot ...