描述 Description
基德穿破层层障碍终于来到了"忧郁的生日"面前."忧郁的生日"如前题所述封存于密码锁中.这个密码锁不是一般的密码锁,这是不一
般的密码锁!这个密码锁上显示着一串数字.旁边还有一串提示:The password is in the number.The number is on screen,you s-
hould delete N numbers as 1,2 or 3...9.The last number should be the smallest of all.The last number is the passwo-
rd(基德:靠,提示居然是E文,无视我400的智商吗?!).为了成功盗取并尽快赶去青子家,基德请你编一个程序解决这个密码锁。
输入格式 Input Format
输入共2行
第一行为一个不超过250位的数字;
第二行则为N。
输出格式 Output Format
输出只有一行,即PASSWORD.
样例输入 Sample Input
178543
4
样例输出 Sample Output
13
我写的程序是:
#include<stdio.h>
#include<string.h>
int fac(int a,int b)
{int hanshu;
if(a>b)
hanshu=a;
else
hanshu=b;
return hanshu;
}
int main()
{
int a[250],i,len,n,b[250]={0};
char s[250];
scanf("%s",s);
len=strlen(s);
scanf("%d",&n);
for(i=0;i<len;i++)
{
a=s-'0';
}
int t,k,j=0;
int sum,xunhuan,x,f;
i=0;
sum=len-n;
x=sum;
f=sum;
for(xunhuan=0;xunhuan<x;xunhuan++)
{
for(t=j+1;t<len;t++)
{
k=fac(a[j],a[t]);
if(k>a[t])
{
j=t;
}
if(t==(len-1))
{
b=a[j];
i=i+1;
j++;
}
}
}
sum=len-n;
for(i=0;i<sum;i++)
printf("%d",b);
return 0;
}