A. Little Artem and Presents
来源:互联网 发布:网络代购英文怎么说 编辑:程序博客网 时间:2024/06/06 15:47
Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present she received, so Artem can't give her the same number of stones twice in a row. For example, he can give her 3 stones, then 1 stone, then again 3 stones, but he can't give her 3 stones and then again 3 stones right after that.
How many times can Artem give presents to Masha?
The only line of the input contains a single integer n (1 ≤ n ≤ 109) — number of stones Artem received on his birthday.
Print the maximum possible number of times Artem can give presents to Masha.
1
1
2
1
3
2
4
3
In the first sample, Artem can only give 1 stone to Masha.
In the second sample, Atrem can give Masha 1 or 2 stones, though he can't give her 1 stone two times.
In the third sample, Atrem can first give Masha 2 stones, a then 1 more stone.
In the fourth sample, Atrem can first give Masha 1 stone, then 2 stones, and finally 1 stone again.
解题说明:最大的次数肯定是2,1,2,1这样的顺序给,判断n和3的关系即可。
#include<cstdio>#include <cstring>#include<cmath>#include<iostream>#include<algorithm>#include<vector>#include <map>using namespace std;int main(){ int n ; scanf("%d",&n); printf("%d\n",(2*n+1)/3); return 0;}
- A. Little Artem and Presents
- CodeForces 669A Little Artem and Presents
- CodeForces 669A Little Artem and Presents
- 【CodeForces】669A - Little Artem and Presents
- 【CodeForces】[669A]Little Artem and Presents
- CodeForces 669A Little Artem and Presents
- codeforces 669A Little Artem and Presents
- 【CodeForces】669A - Little Artem and Presents(找规律)
- Codeforces Round #348 (div 2) A. Little Artem and Presents
- 【codeforce】-#669A-Little Artem and Presents(数学,找规律)
- Codeforces 669A Little Artem and Presents(数量不同送礼物)
- 13周练J - Little Artem and Presents【规律】
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-A. Little Artem and Presents(模拟)
- CodeForces 668A Little Artem and Matrix
- CF Round #348 Div. 2 A. Little Artem and Present B. Little Artem and Grasshopper C. Little Artem and
- ACM刷题之Codeforces————Little Artem and Presents
- Little Artem and Grasshopper
- CodeForces 669ALittle Artem and Presents
- 欧拉函数的性质及应用
- 修改Idea默认的全局设置,如Maven等
- RecyclerView实现加载更多
- HBase的RPC源码分析
- SQL Server2005连接Oracle 11g详细步骤
- A. Little Artem and Presents
- (词法结构)JavaScript权威指南笔记2
- 遍历python字典几种方法
- (01)javascript 数据类型
- #116 – Dependency Property Values Are Stored in the DependencyObject(依赖属性存储在DependencyObject中)
- Exception in thread "http-bio-8080-exec-10" java.lang.OutOfMemoryError: PermGen space
- handlebars自定义helper的写法
- 携车网产品线框图
- CentOS 6.5 搭建PHP环境(Nginx+MariaDB+PHP7)