我的代码有问题吗?
查看原帖
我的代码有问题吗?
1264600
Lazy_make_name楼主2024/10/28 21:56
#include<iostream>
using namespace std;
int main(){
	int t,n,db[27]={-1,-1,1,7,4,2,6,8,10,18,22,20,28,68,88,108,188,200,208,288,688,888,1088,1888,2008,2088,2888};
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		if(n<=27){
			cout<<db[n];
		}
		else{
			switch(n%7){
				case 0:
				for(int j=1;j<=n/7;j++){
					cout<<'8';
				}break;
				case 1:
				cout<<"10";
				for(int j=1;j<=n/7-1;j++){
					cout<<'8';
				}break;
				case 2:
				cout<<'1';
				for(int j=1;j<=n/7;j++){
					cout<<'8';
				}break;
				case 3:
				cout<<"200";
				for(int j=1;j<=n/7-2;j++){
					cout<<'8';
				}
				case 4:
				cout<<"20";
				for(int j=1;j<=n/7-1;j++){
					cout<<'8';
				}
				case 5:
				cout<<"2";
				for(int j=1;j<=n/7;j++){
					cout<<'8';
				}
				case 6:
				cout<<"6";
				for(int j=1;j<=n/7;j++){
					cout<<'8';
				}
			}
		}
	}
	return 0;
}
2024/10/28 21:56
加载中...