暴力样例都过了也不至于0分吧
查看原帖
暴力样例都过了也不至于0分吧
1066396
szm111213楼主2024/10/26 19:42
#include <bits/stdc++.h>
using namespace std;
int c[20] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}, n;
int check1(char a)
{
	if(a == '1') return 1;
	if(a == '2') return 2;
	if(a == '3') return 3;
	if(a == '4') return 4;
	if(a == '5') return 5;
	if(a == '6') return 6;
	if(a == '7') return 7;
	if(a == '8') return 8;
	if(a == '9') return 9;
	if(a == '0') return 0;
}
bool check(int x)
{
	string k = to_string(x);
	int kk = 0;
	for(int i = 0; i < k.size(); i ++)
	{
		kk += c[check1(k[i])];
	}
	if(kk == n)
	{
		return true;
	}
	return false;
}
int main()
{
    int t;
    cin >> t;
    bool flag = 1;
    for(int i = 1; i <= t; i ++)
    {
		cin >> n;
		for(int j = 1; j <= 100000; j ++)
		{
			if(check(j))
			{
				flag = 0;
				cout << j << endl;
				break;
			}
		}
		if(flag == 1)
		{
			cout << -1 << endl;
		}
	}
    return 0;
}

各位大佬,只要5分就够了

2024/10/26 19:42
加载中...