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 ...
随机推荐
- spring aop提供了两种实现方式jdk和cglib
Spring AOP使用了两种代理机制:一种是基于JDK的动态代理:另一种是基于CGLib的动态代理.之所以需要两种代理机制,很大程度上是因为JDK本身只提供接口的代理,而不支持类的代理. Sprin ...
- java 图片加水印,设置透明度。说明非常具体
package com.yidao.common; import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.aw ...
- 记一次CDH修改IP
因机房服务器搬迁,需要修改CDH ip ,集群中有6台服务器. 其中配置了ldap,其中卡在了ldap中的坑太深,所以记录一下. 一.服务器IP等地址修改 1.首先在安装cloudera-manage ...
- Git以及github的使用方法(四),版本回退
现在,你已经学会了修改文件,然后把修改提交到Git版本库,现在,再练习一次,修改readme.txt文件如下: Git is a distributed version control system. ...
- ASP.Net MVC开发基础学习笔记(8):新建数据页面
前言 前面解说了怎样创建一个查询页面并给查询页面加入排序.搜索及分页功能.今天我们来讲讲怎样向这个列表加入数据. 解说的顺序将依照加入数据的步骤的时间顺序来进行,方便大家理清逻辑关系. 本节将涉 ...
- svn 命令个
svn 命令行下常用的几个命令 标签: svnpathdelete工作urlfile 2011-11-28 08:16 128627人阅读 评论(1) 收藏 举报 分类: 版本控制(8) 版权声明 ...
- Java与设计模式-责任链模式
责任链模式属于行为型设计模式之中的一个,怎么理解责任链?责任链是能够理解成数个对象首尾连接而成,每个节点就是一个对象.每个对象相应不同的处理逻辑,直至有一个对象响应处理请求结束.这一种模式成为责任链模 ...
- 【BZOJ3505】[Cqoi2014]数三角形 组合数
[BZOJ3505][Cqoi2014]数三角形 Description 给定一个nxm的网格,请计算三点都在格点上的三角形共有多少个.下图为4x4的网格上的一个三角形. 注意三角形的三点不能共线. ...
- js怎么select 选中的值
var obj = document.getElementById(”SelectID”); var index = obj.selectedIndex; // 选中索引var text = obj. ...
- 在c代码中获取用户环境变量
1 extern char ** environ 这是一个字符串数组,最后一个元素是null,即\0. 2 在代码中的使用方法 直接extern char **environ,然后 直接environ ...