s1=(y-x);s2=l-s1;
if(a>b){t=s1/(a-b);printf("%d\n",t);}
elseif(a
elseprintf("impossible\n");
}
else{
s1=x-y;s2=l-s1;
if(a>b){t=s2/(a-b);printf("%d\n",t);}
elseif(a
elseprintf("impossible\n");
}
return0;
}
22.
#include
#include
int main()
{
int N,i,j,k,x,a,cnt=0;
scanf("%d",&N);
for(k=7;k<=N;k++)
{
j=k;
for(i=4;i>=0;i--)
{
a=(int)pow(10,i);
x=j/a;
if(x==7||k%7==0)
{
printf("%d ",k);
break;
}
else j=j-a*x;
}
}
return 0;
}
23.
#include
intmain()
{
inta,b,c,d,e,f,g,h,i,j,n;
scanf("%d",&n);
if(n<2||n>79)printf("error\n");
for(j=0;j<=9;j++)
for(i=0;i<=9;i++)if(i==j)continue;
elsefor(h=0;h<=9;h++)if(h==j||h==i)continue;
elsefor(g=0;g<=9;g++)if(g==h||g==i||g==j)continue;
elsefor(f=0;f<=9;f++)if(f==g||f==h||f==i||f==j)continue;
elsefor(e=0;e<=9;e++)if(e==f||e==g||e==h||e==i||e==j)continue;
elsefor(d=0;d<=9;d++)if(d==e||d==f||d==g||d==h||d==i||d==j)continue;
elsefor(c=0;c<=9;c++)if(c==d||c==e||c==f||c==g||c==h||c==i||c==j)continue;
elsefor(b=0;b<=9;b++)if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==j)continue;
elsefor(a=0;a<=9;a++)if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==j)continue;
elseif(double(a*10000+b*1000+c*100+d*10+e)/double(f*10000+g*1000+h*100+i*10+j)==n)
printf("%d%d%d%d%d/%d%d%d%d%d=%d\n",a,b,c,d,e,f,g,h,i,j,n);
elsecontinue;
return0;
}
24。
#include
intmain()
{inta=1,b1=0,b2,t,n;
scanf("%d",&t);
for(n=1;n<=t;n++)
{b2=2*b1+3*a;
a=b1;
b1=b2;
}
printf("%d%d\n",a,b2);
return0;
}
25.
#include
#include
int main()
{
long s=0,l=0,m=0;
int n=0,i=0,j=0,k=0;
scanf("%d",&n);
for(s=14000;;s++)
{
for(i=1;i<=99;i+=2)
{
l=s*100+i;
for(m=3;m<=(int)pow(l,0.5);m+=2)
{
if(l%m==0)
{
goto B;
}
}
goto A;
B:
;}
k++;
if(n==k)
{
printf("%ld %ld\n",s*100,l);
break;