CodeForces 669A Little Artem and Presents
2016-04-27 16:00
309 查看
题意:同学有n个糖果,然后每一次可以给人任意个糖果,但是给出去的糖果数量得保证和上一次的数量不一样。问你最多能给多少手
思路:显然是1 2 1 2 1 2这样的...
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 her3 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
思路:显然是1 2 1 2 1 2这样的...
#include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); printf("%d\n",(n/3)*2+((n%3)?1:0)); }
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 her3 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
相关文章推荐
- Android关机流程
- S2SH 导出excel
- MongoDB身份验证--命令行模式
- trigger
- c#大圣之路笔记—— C#连接数据库
- python的稀疏矩阵计算
- PHP中关于foreach的笔试题
- Apache Nutch v2.3 发布,Java实现的网络爬虫
- C# 位运算轻松实现权限操作
- 关于setw(8)和向文本中写入内容的用法及说明
- 康托展开 全排列
- 如何在WPF中调用Winform控件
- Kubernetes Minion Node 组件 之 Kubelet
- 绑定qt的sqldriver一起发布。
- swift - mutating(杖举或结构体,通过方法来改变自身的值)
- postgresql pgAgent 定时任务
- 使用WakeLock使Android应用程序保持后台唤醒
- Postgresql FATAL: could not create semaphores: No space left on device
- 为什么Java中1000==1000为false而100==100为true?
- Exercise(10):N个2015(待解)