Supreme Number

 

//特别坑   371, 713, 731 都不是素数 

/*#include <iostream>
#include <math.h>
using namespace std;
int a[] = {1, 2, 3, 5, 7,11, 13, 17, 23, 31, 37, 53, 71, 73, 113, 131,  137, 173, 311, 317, 371,  713, 731};
int isPrime(long long n)
{	//返回1表示判断为质数,0为非质数,在此没有进行输入异常检测
    float n_sqrt;
    if(n==2 || n==3) return 1;
    if(n%6!=1 && n%6!=5) return 0;
    n_sqrt=floor(sqrt((float)n));
    for(int i=5;i<=n_sqrt;i+=6)
    {
        if(n%(i)==0 | n%(i+2)==0) return 0;
    }
    return 1;
}
int main() {
    int flag;
    long long n;
    // cin >> n;
     for(long long i=0; i<23; i++) {
    if (isPrime(a[i]))
        cout << a[i] << " ";
    else cout << "NO is" << a[i] << endl;
}
    return 0;
}
*/
#include <iostream>
#include <string>
using namespace std;

int a[] = {1, 2, 3, 5, 7,11, 13, 17, 23, 31, 37, 53, 71, 73, 113, 131,  137, 173, 311, 317, 371,  713, 731};

int main()
{
    int N;

    string s;

    cin >> N;

    for(int i=1; i<=N; i++) {
        cin >> s;
        int t = 0;
        int cnt = 0;
              int j=s.size();
              if(j >= 4)
                  t = 1000;
              else
                  for(j = 0; s[j]; j++)
                  {
                      t *= 10;

                      t += s[j]-'0';

                  }

            cout << "Case #" << i << ": ";
     /*       if (t >= 731)
                cout << "731" << endl;
            else if (t >= 713)
                cout << "713" << endl;
            else if (t >= 371)
                cout << "371" << endl;*/
        if (t >= 317)
                cout << "317" << endl;
            else if (t >= 311)
                cout << "311" << endl;
            else if (t >= 173)
                cout << "173" << endl;
            else if (t >= 137)
                cout << "137" << endl;
            else if (t >= 131)
                cout << "131" << endl;
            else if (t >= 113)
                cout << "113" << endl;

            else if (t >= 73)
                cout << "73" << endl;

            else if (t >= 71)
                cout << "71" << endl;
            else if (t >= 53)
                cout << "53" << endl;

            else if (t >= 37)
                cout << "37" << endl;
            else if (t >= 31)
                cout << "31" << endl;
            else if (t >= 23)
                cout << "23" << endl;
            else if (t >= 17)
                cout << "17" << endl;
            else if (t >= 13)
                cout << "13" << endl;
            else if (t >= 11)
                cout << "11" << endl;
            else if (t >= 7)
                cout << "7" << endl;
            else if (t >= 5)
                cout << "5" << endl;
            else if (t >= 3)
                cout << "3" << endl;

            else
                cout << "2" << endl;

        }

    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值