codeforces 669A A. Little Artem and Presents(水题)
题目链接:
2 seconds
256 megabytes
standard input
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?
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了;
AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+;
const ll inf=1e15;
const int N=1e5+; int main()
{ int n;
scanf("%d",&n);
if(n%==)printf("%d\n",n/*);
else if(n%==)printf("%d\n",n/*+);
else
{
printf("%d\n",n/*+);
}
return ;
}
codeforces 669A A. Little Artem and Presents(水题)的更多相关文章
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Littl ...
- codeforces 669B B. Little Artem and Grasshopper(水题)
题目链接: B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megaby ...
- codeforces 669C C. Little Artem and Matrix(水题)
题目链接: C. Little Artem and Matrix time limit per test 2 seconds memory limit per test 256 megabytes i ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...
随机推荐
- 【mac IntelliJ Idea】mac上 idea快速重写父类方法 快捷键
windows上快捷键: Ctrl+O Mac上快捷键: command+O 在要重写父类方法的位置 ,按下快捷键,然后选择要重写的方法即可.
- Docker实战(一):基础命令
# 在ubuntu中安装docker $ sudo apt-get install docker.io # 查看docker的版本信息 $ docker version # 查看安装docker的信息 ...
- 一个Netfilter nf_conntrack流表查找的优化-为conntrack添加一个per cpu cache
独悲须要忍受.快乐须要分享对Linux协议栈多次perf的结果,我无法忍受conntrack的性能,然而它的功能是如此强大,以至于我无法对其割舍,我想自己实现一个高速流表.可是我不得不抛弃依赖于con ...
- IOS 开发推荐经常使用lib
1. Mantle Mantle 让我们能简化 Cocoa 和 Cocoa Touch 应用的 model 层.简单点说.程序中常常要进行网络请求,请求到得通常是 json 字符串.我们通常会建一个 ...
- match excel test search replace 用法
1 test:测试string是否包含有匹配结果,包含返回true,不包含返回false. 2 reg.test(str) 3 <script type="text/javascrip ...
- 串匹配算法之BM算法
参考资料: http://blog.csdn.net/eric491179912/article/details/6210009 http://blog.163.com/pengfeicui@ye ...
- vs2012编译ffmpeg
从官方网站down下来的ffmpeg没有pdb文件不方便调试,为此使用VS2012编译ffmpeg. 编译步骤: 一.安装MinGW,具体的安装方法上一篇文章已经有介绍这里不在赘述. 二.下载文件并放 ...
- docker安全最佳实践概述
/************************************************* * Author : Samson * Date : 08/07/2015 * Test plat ...
- Ubuntu 登陆异常-输入正确的密码后还会返回到登陆界面的问题
问题表现: 启动到了登陆界面,输入对应的密码,发现一闪黑屏有返回到登陆界面,如此往复. 解决方法: 开机后在登陆界面按下shift + ctrl + F1进入tty命令行终端登陆,可以查看用户主目录下 ...
- xcode打包 提交到iTunesConnect
1.首先确定发布app的所必要选中或者切换的弄好 比如切换环境到 由测试环境切换到正式环境. 2.打发布包 首先选中Product 然后选中Archive. 3.等待编译. 4.打包成功 会进入到下面 ...