求助,玄关30分
  • 板块灌水区
  • 楼主Nobel
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/10/25 08:24
  • 上次更新2024/10/25 11:25:20
查看原帖
求助,玄关30分
1300391
Nobel楼主2024/10/25 08:24

题目:T255017 【pty2022】编号

#include <iostream>
using namespace std ;
int vis[1000005] ;
bool chect( int x  )
{
	while( x )
	{
		int t = x % 10 ;
		if( vis[t] == 0 )
		{
			return false ;
		}
		x /= 10 ;
	}
	return true ;
}
int main()
{
	int n , k ;
	cin >> n >> k ;
	for( int i = 1 ; i <= k ; i ++ )
	{
		int x ;
		cin >> x ;
		vis[x] = 1 ;
	}
	if( k == 1 )
	{
		int x ;
		for( int i = 1 ; i <= 9 ; i ++ )
		{
			if( vis[i] )
			{
	            x = i ;	
			}
		}
		for( int i = 1 ; i <= n ; i ++ )
		{
			cout << x ;
		}
	}
	else if( k == 10 ) cout << n - 1 ;
	else
	{
		int cnt = 0 , star = 1 ;
		if( vis[0] == 1 )
		{
			star = 0 ;
		}
		for( int i = star ; ; i ++ )
		{
			cnt ++ ;
			if( chect(i) )
			{
				cout << i ;
				break ;
			}
		}
	}
	return 0 ; 
}
2024/10/25 08:24
加载中...