80分求调
查看原帖
80分求调
1345586
HMZ168楼主2024/11/9 22:37
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

void shu(int s, bool ed)
{
    if (s <= 0)
    {
        cout << -1;
    }
    else if (s == 1)
    {
        cout << -1;
    }
    else if (s == 3)
    {
        cout << 7;
    }
    else if (s == 10)
    {
        cout << 22;
    }
    else
    {
        int y, c;
        y = s % 7;
        c = s / 7;
        switch (y)
        {
        case 1:
            cout << 10;
            c--;
            break;
        case 2:
            cout << 1;
            break;
        case 3:
            cout << 200;
            c = c - 2;
            break;
        case 4:
            cout << 20;
            c--;
            break;
        case 5:
            cout << 2;
            break;
        case 6:
            cout << 6;
            break;
        }
        for (int i = 0; i < c; i++)
        {
            cout << 8;
        }
    }
    if (!ed)
    {
        cout << endl;
    }

    return;
}

int main()
{
    int k, n = 0;
    cin >> k;
    int m[100];
    for (int x0 = 0; x0 < k; x0++)
    {
        cin >> m[x0];
    }

    for (int n = 0; n < k; n++)
    {
//        if (n == k - 1)
//        {
//           shu(m[n], true);
//        }else{
            shu(m[n], false);
//        }
        
    }

    return 0;
}
2024/11/9 22:37
加载中...