【codeforce】-#669A-Little Artem and Presents(数学,找规律)
2016-05-26 13:25
411 查看
点击打开题目
A. Little Artem and Presents
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 3stones
and then again 3 stones right after that.
How many times can Artem give presents to Masha?
Input
The only line of the input contains a single integer n (1 ≤ n ≤ 109) —
number of stones Artem received on his birthday.
Output
Print the maximum possible number of times Artem can give presents to Masha.
Examples
input
output
input
output
input
output
input
output
Note
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.
找数学规律,112334556778.........
A. Little Artem and Presents
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 3stones
and then again 3 stones right after that.
How many times can Artem give presents to Masha?
Input
The only line of the input contains a single integer n (1 ≤ n ≤ 109) —
number of stones Artem received on his birthday.
Output
Print the maximum possible number of times Artem can give presents to Masha.
Examples
input
1
output
1
input
2
output
1
input
3
output
2
input
4
output
3
Note
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.
找数学规律,112334556778.........
#include<cstdio> int main() { int n,x,y,ans; while(~scanf("%d",&n)) { x=n%3; y=n/3; if(x!=0) ans=2*y+1; else ans=2*y; printf("%d\n",ans); } return 0; }
相关文章推荐
- 编程小练习
- 155. Min Stack
- zabbix 监控 nginx性能
- 浅谈android中的ListView之解决ScrollView和ListView嵌套冲突(实际上一切都是浮云,闲的蛋疼)(一)
- js常用事件总结及案例-onSubmit
- SQL 存在一个表而不在另一个表中的数据
- ACM学习历程—Codeforces Round #354 (Div. 2)
- 线程和进程的区别和联系
- DB2中使用事件监控器获取某个时间段里某个用户执行的SQL语句
- 创建数据库类实现 增删改查功能
- javax.el.PropertyNotFoundException: Property 'emailaddress' not found on type ja
- iOS开发之Xcode优化,清理Xcode编译缓存,清除provisioning profile 证书,添加provisioning profile证书
- 欢迎使用CSDN-markdown编辑器
- 编程小练习
- Tomcat 安装与环境变量配置
- SSL peer certificate or SSH remote key was not OK
- 第二次冲刺周期个人工作总结02
- 如何更改java应用程序标题栏默认图标
- 栏目跳转 用iframe加载页面 ajax加载页面在div中
- DragView(二)