【CodeForces】669A - Little Artem and Presents
2016-05-27 08:11
316 查看
Description
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.
Sample Input
Input
Output
Input
Output
Input
Output
Input
Output
3
#include<stdio.h>
#include<string.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int ans=0;
for(int i=1;n>=0;i++)
{
if(i%2!=0)
{
n--;
ans++;
}
else
{
n-=2;
ans++;
}
}
printf("%d\n",ans-1);
}
}
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.
Sample Input
Input
1
Output
1
Input
2
Output
1
Input
3
Output
2
Input
4
Output
3
#include<stdio.h>
#include<string.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int ans=0;
for(int i=1;n>=0;i++)
{
if(i%2!=0)
{
n--;
ans++;
}
else
{
n-=2;
ans++;
}
}
printf("%d\n",ans-1);
}
}
相关文章推荐
- 【CodeForces】670A - Holidays
- ios 微信登录
- 团队冲刺2---个人工作总结三(5.27)
- 第二冲刺阶段 工作总结 04
- HDU 1102 Constructing Roads
- CSS动画--页面特效
- CocoaPods的安装,升级以及升级以后出现bug的解决方法(升级必看!)
- Watchmen(排列,去重)
- 用JS获取地址栏参数的方法
- 哈希表总结
- 第三章 自定义控件
- bzoj 4555:[Tjoi2016&Heoi2016]求和 多项式求逆
- 三观 - 三观 - 三观
- 删除文件,du观察空间已经删除,但df观察空间仍被占用的解决方法
- 【编程马拉松算法目录】
- 第二期冲刺每日站立会议——20160527
- 团队项目-个人博客5.27
- eclipse打开时如何查找jre
- PTA 数据结构 01-复杂度2 Maximum Subsequence Sum (25分)
- 2016"百度之星" - 初赛(Astar Round2B)