lucky number 被恶心到的一题目
Problem F:Lucky numbers
Time Limit:1000MS Memory Limit:65536K
Total Submit:108
Accepted:14
Description
Digits 6 and 8 are lucky, while all
others are unlucky. An integer is lucky if it contains only lucky digits
in
decimal notation. We would like to know the K-th lucky positive integer.
Input
The first and only line of input contains a positive integer K (1 ≤ K ≤ 109).
Output
The first and only line of output must contain the K-th lucky positive integer.
Sample Input
1
2
3
Sample Output
6
8
66
#include<stdio.h>
#include<string.h>
int k;
int ch[130]={0,6,8,66,68,86,88,666,668,686,688,866,868,886,888,6666,6668,6686,6688,6866,6868,6886,6888,8666,8668,8686,8688,8866,8868,8886,8888,66666,66668,66686,66688,66866,66868,66886,66888,68666,68668,68686,68688,68866,68868,68886,68888,86666,86668,86686,86688,86866,86868,86886,86888,88666,88668,88686,88688,88866,88868,88886,88888,666666,666668,666686,666688,666866,666868,666886,666888,668666,668668,668686,668688,668866,668868,668886,668888,686666,686668,686686,686688,686866,686868,686886,686888,688666,688668,688686,688688,688866,688868,688886,688888,866666,866668,866686,866688,866866,866868,866886,866888,868666,868668,868686,868688,868866,868868,868886,868888,886666,886668,886686,886688,886866,886868,886886,886888,888666};
void chart( )
{
int d = 6;
for( int i = 1; i < 120; ++d )
{
int d1 = d,f = 1;
while( d1 )
{
int t = d1 % 10;
d1 /= 10;
if( t != 8 && t != 6 )
{
f = 0;
break;
}
}
if( f )
{
ch[i++] = d;
printf( "%d,",d );
}
}
}
int main( )
{
freopen ( "1.out", "w", stdout );
memset( ch,0,sizeof( ch ) );
chart( );
int k;
while( scanf( "%d",&k ) ==1 )
printf( "%d\n",ch[k] );
return 0;
}
还是没过,不知为啥??
本人还是新手 ,转载请注明来自Lvsi‘s home