zoukankan      html  css  js  c++  java
  • 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

    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

    1

    Sample Output

    1

    Hint

    题意

    A同学有n个糖果,然后每一次可以给人任意个糖果,但是给出去的糖果数量得保证和上一次的数量不一样。

    问你最多能给多少手

    题解:

    肯定就这样嘛,1 2 1 2 1 2 1 2,这样贪心一波就好了

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        long long n;cin>>n;
        cout<<(n/3)*2+((n%3)?1:0)<<endl;
    }
  • 相关阅读:
    pushlet 模式设定和session超时设定
    sql 排名
    Create Async Tree 的使用
    SQL 高级查询 50题
    pushlets 网址
    jsp 页面解析json字符串
    响应式WEB设计
    上传图片 并生成缩略图的 例子 C#.net
    profile 实现购物车 实例 (二)
    profile 实现购物车 实例(一)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5432532.html
Copyright © 2011-2022 走看看