Codeforces Beta Round #74 (Div. 2 Only) A题

来源:互联网 发布:dnf网络卡会丢伤害吗 编辑:程序博客网 时间:2024/05/30 05:11

这道题目,静下心来就应该可以想出来,我当时没有想到!#include <iostream>#include <cstdio>#include <cstring>#include <string>using namespace std;int pp(int n){    if(n==1)n-=1;    if(n>=2)n-=2;    return n;}int main(){    int r,g,b;    int time=0;    while(scanf("%d%d%d",&r,&g,&b)==3)    {        while(1)        {            if(time%3==0&&r)                r=pp(r);            if(time%3==1&&g)                g=pp(g);            if(time%3==2&&b)                b=pp(b);            if(r==0&&g==0&&b==0)break;            time++;//这个一定是放在这里,不能放在前面,这样就会出错,理由很简单,当r==0,g==0,b==0时,满足第一个条件,就会++,就算不满足也会++        }        printf("%d\n",time+30);    }    return 0;}