zoukankan      html  css  js  c++  java
  • Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A

    A. Little Artem and Presents
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    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?

    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.

    Examples
    Input
    1
    Output
    1
    Input
    2
    Output
    1
    Input
    3
    Output
    2
    Input
    4
    Output
    3
    Note

    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为Artem拥有的石头的数量 现在送给Masha 每次送的个数不能与上次想用 问最多能送几次;

    题解:看明白题意  1 2 1 2 的序列;

    我yan 码 

     1 #include<iostream>
     2  #include<cstring>
     3  #include<cstdio>
     4  #include<queue>
     5  #include<stack>
     6  #include<map>
     7  #include<set>
     8  #include<algorithm>
     9  #define ll __int64
    10  #define pi acos(-1.0)
    11  #define mod 1
    12  #define maxn 10000
    13  using namespace std;
    14  int n;
    15  ll ans;
    16  int main() {
    17     cin>>n;
    18     if(n%3==0) 
    19         ans = (n/3)*2;
    20     else 
    21        ans = (n/3)*2 + 1;
    22     cout<<ans<<endl;
    23     return 0;
    24 }
  • 相关阅读:
    分布式系统之CAP原理
    分布式缓存一致性哈希算法
    数据库三范式 无重复列 完全依赖主键 属性不依赖非主属性
    二叉树 B-树B+树
    数据库索引 主键 聚集索引 非聚集索引
    数据库水平拆分
    线程池ScheduledThreadPoolExecutor
    线程池之ThreadPoolExecutor
    mybatis一级缓存和二级缓存
    vue框架的搭建
  • 原文地址:https://www.cnblogs.com/hsd-/p/5429165.html
Copyright © 2011-2022 走看看