[2016-04-25][codeforces][669][A]Little Artem and Presents]

  • 时间:2016-04-25 19:50:32 星期一

  • 题目编号:[2016-04-25][codeforces][669][A]Little Artem and Presents]

  • 题目大意:有n个礼物送给某人,每次送的礼物的数目不能和上次一样,问最多能送多少次

  • 分析:

    • 贪心,1,2,1,2交替送,剩下的不管是1个还是2个,最多只能送一次
    • 答案:ans = n / 3 * 2 + (n % 3? 1 :0)
  • 遇到的问题:

  1. #include<cstdio>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. scanf("%d",&n);
  6. int ans = n / 3 * 2 + (n%3?1:0);
  7. printf("%d\n",ans);
  8. return 0;
  9. }


来自为知笔记(Wiz)


posted on 2016-04-25 19:53  红洋  阅读(173)  评论(0)    收藏  举报

导航