和泉纱雾

和泉纱雾
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description

众所周知,和泉纱雾是著名的埃罗芒阿老师,画画功力首屈一指。今天我们的埃罗芒阿老师又开启了天真无邪嗨嗨嗨的模式。

3880-1(←埃罗芒阿)

在这里插入图片描述她现在想要画一些数字(不包括 0),然后她现在有染料 n。对于每个数字消耗的染料:
3880-2
如图所示:分别对应 2,5,5,4,5,6,3,7,6。
现在纱雾想知道的是她能画出的最大的十进制的数是多大。
Input

输入数据有多组(数据组数不超过 100),到 EOF 结束。
对于每组数据,输入一行,包含一个整数 n (0 <= n <= 100000)。
Output

对于每组数据,如果纱雾画不出数字,请输出 “QAQ”(不包括引号),否则输出纱雾能画出的最大的数字。
Sample Input

4
Sample Output

11
Hint

她有染料 4,可以选择涂两个 1 或者 1 个 4。很明显 11 > 4。所以应当画 11。

#include<stdlib.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int n;
    char s[50001];
    while(cin>>n)
    {
         if(n<2)
             cout<<"QAQ"<<endl;
        else
            if(n==2)
                cout<<1<<endl;
        else
            if(n==3)
                cout<<"7"<<endl;
        else
            if(n==4)
                cout<<"11"<<endl;
        else
            if(n==5)
                cout<<"71"<<endl;
        else
        {
            int k=n/2;
            int p=n%2;
            
            
            for(int i=1;i<=k;i++)
                s[i]='1';
            if(p==0)
            {
                for(int i=1;i<=k;i++)
                    cout<<s[i];
                cout<<endl;
            }
            else
            {
                s[1]='7';
                for(int i=1;i<=k;i++)
                    cout<<s[i];
                cout<<endl;
            }
        }
   }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/dongjian2/article/details/89636334