ACM刷题之Codeforces————Little Artem and Presents
2016-04-27 15:38
141 查看
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
3 stones 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.
水题。看三的倍数。
下面是ac代码
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
3 stones 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.
水题。看三的倍数。
下面是ac代码
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> using namespace std; int main() { __int64 a,b; while(scanf("%I64d",&a)!=EOF) { if(a%3==0) printf("%I64d\n",2*a/3); else if(a%3==1||a%3==2) printf("%I64d\n",(a/3)*2+1); } }
相关文章推荐
- ORA-00257归档日志写满的解决方法
- linux私房菜学习笔记—vim编辑器
- C# IsExistWindow函数写法及调用
- select2 模态框中无法智能搜索
- .net new object structure
- Android studio 快捷键小计
- spring 整合CXF框架抛异常
- 编程珠玑之第二章
- spring boot test
- Java数据结构--排序
- C# 委托如何理解 打个比喻
- iframe 父子页面调用方法
- django数据库时间存储格式问题
- TS流解析之一解包长
- redis 集群搭建 Ubuntu
- CoInitializeEx 与CoInitialize的区别
- C语言编程优化运行速度
- Android之GPS定位网上详解总结
- Android 内存泄露简介、典型情景及检测解决
- 一个经典例子让你彻彻底底理解java回调机制