The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemA:Accurately Say "CocaCola"!

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2965

题意:一群人玩过“7”的游戏,有7的数字或者7的倍数就要喊“cocacola”。给出一个数字p,求连续要喊“cocacola”p次的最小数字s;

思路:刚开始想着,2是27,3-10都是70,11-100都是700。。。后来一直WA,打个表才知道,270-280有11个。。。。所以....

#include<bits/stdc++.h>
using namespace std;
int main() {
    int t,p,s;
    cin>>t;
    while(t--) {
        cin>>p;
        if(p==1)
            s=7;
        else if(p==2)
            s=27;
        else if(p>2&&p<=10)
            s=70;
        else if(p==11)
            s=270;
        else if(p>11&&p<=100)
            s=700;
        cout<<s<<endl;
    }
    return 0;
}

 

你可能感兴趣的:(The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemA:Accurately Say "CocaCola"!)