求解答
查看原帖
求解答
878098
Distorted_Fate_楼主2024/10/26 21:25
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
#define int long long
int a[N]={6,2,5,5,4,5,6,3,7,6};
int t;
int fen(int x){
	int ans=0;
	while(x){
		ans+=a[x%10];
		x/=10;
	}
	return ans;
}
signed main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(int i=10;i<=N;i++){
		a[i]=fen(i);
	}
	cin>>t;
	while(t--){
		bool f=0;
		int n;
		cin>>n;
		for(int i=1;i<=N;i++){
			if(a[i]==n){
				f=1;
				cout<<i<<endl;
				break;
			}
		}
		if(f==0)cout<<-1<<endl;
	}
	return 0;
}

RT,全RE

赛时代码,想骗n<=1e3的点,交到洛谷全RE了,求解答,本人太弱勿喷……

2024/10/26 21:25
加载中...