Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-A. Little Artem and Presents(模拟)
来源:互联网 发布:知乎怎么发帖子 编辑:程序博客网 时间:2024/04/28 10:26
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.
题意:
给你n个石头,要相邻两次数量不同,而且次数最多。
思路:
1+2为一次循环,所以只要除以3然后就是看是否大于0,大于的话就可以给一个石头了。
AC代码:
#include<iostream>#include<functional>#include<algorithm>#include<cstring>#include<string>#include<vector>#include<cstdio>#include<cmath>#include<map>using namespace std;#define CRL(a) memset(a,0,sizeof(a))#define QWQ ios::sync_with_stdio(0)typedef unsigned __int64 LL;typedef __int64 ll;const int T = 1000000+50;const int mod = 1000000007;const double PI = 3.1415926535898;int main(){#ifdef zscfreopen("input.txt","r",stdin);#endifll n,m,i,j,k;while(~scanf("%I64d",&n)){printf("%I64d\n",n/3*2+((n%3!=0)?1:0));}return 0;}
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-A. Little Artem and Presents(模拟)
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-B. Little Artem and Grasshopper(模拟)
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) E. Little Artem and Time Machine 树状数组
- Codeforces Round #348 (div 2) A. Little Artem and Presents
- [2-SAT] Codeforces 668E #348 (VK Cup 2016 Round 2, Div. 1 Edition) E. Little Artem and 2-SAT
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A B C D 模拟
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A B C D 构造
- Codeforces VK Cup 2016 - Round 1 (Div. 2 Edition)
- VK Cup 2016 - Round 1 (Div. 2 Edition) A B
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition)
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) easy(上)
- Codeforces Round #348 (div 2) C. Little Artem and Matrix
- VK Cup 2016 - Round 1 (Div. 2 Edition) A. Bear and Reverse Radewoosh
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B.Problems for Round
- mailto: HTML e-mail 链接
- java 实现QQ自动登录(带验证码)
- window下安装scala 环境
- 哈理工OJ—1309入侵检测(字符串处--剪枝)
- linux 中 alias 命令用法
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition)-A. Little Artem and Presents(模拟)
- 反向探测>病毒虚拟机"特征"
- Qt简单编程--状态栏(2)
- iOS 开源项目list
- 【AKOJ】1298-B趣味求和
- 江南带你从源码教你解析Volley
- Android 使用颜色矩阵改变图片颜色,透明度,亮度
- 第8章 面向对象编程简介
- 宽字符和字符