# 补♂课第111场解题报告

2017-12-31 21:04:40来源:CSDN作者:w_weilan人点击

# A - 试剂配制

``#include<stdio.h>int n,t,a[8]= {0};int main(){    scanf("%d",&n);    while(n--)    {        scanf("%d",&t);        a[t-1]=1;    }    printf("%d",           !(a[0]&a[1])&           !(a[2]&a[3])&           !(a[4]^a[5])&           (a[6]|a[7]));}``

# B - 异常细胞检测

``#include<stdio.h>int n,cnt=0,a[128][128]= {0};int main(){    scanf("%d",&n);    for(int i=0; i<n; ++i)        for(int j=0; j<n; ++j)            scanf("%d",&a[i][j]);    for(int i=1; i<n-1; ++i)        for(int j=1; j<n-1; ++j)            if(a[i-1][j]>=a[i][j]+50&&                    a[i+1][j]>=a[i][j]+50&&                    a[i][j-1]>=a[i][j]+50&&                    a[i][j+1]>=a[i][j]+50)                ++cnt;    printf("%d",cnt);}``

# C - 按顺序输出

``#include<stdio.h>#include<stdlib.h>int a[3];int intGreaterCmp(const void *a,const void *b){    return *(int*)b-*(int*)a;}int main(){    scanf("%d%d%d",&a[0],&a[1],&a[2]);    qsort(a,3,sizeof(int),intGreaterCmp);    printf("%d %d %d",a[0],a[1],a[2]);}``

# D - 求和

``#include<stdio.h>#include<math.h>int a,n,s=0;int main(){    scanf("%d%d",&a,&n);    for(int i=1; i<=n; ++i)        s+=(pow(10,i)-1)/9*a;    printf("%d",s);}``

# E - 满足条件的整数

``#include<stdio.h>int main(){    for(int a=1; a<=100; ++a)        for(int b=a; b<=100; ++b)            for(int c=b; c<=100; ++c)                if(a*a+b*b==c*c)                    printf("%d*%d + %d*%d = %d*%d/n",                           a,a,b,b,c,c);}``

# F - 吃糖果

``#include<stdio.h>int work(int n){    static int f[32]= {1,1};    if(f[n])return f[n];    return f[n]=work(n-1)+work(n-2);}int main(){    int n;    scanf("%d",&n);    printf("%d",work(n));}``

``int work(int n){    int a=1;    for(int i=2,b=1,c; i<=n; ++i)    {        c=a;        a+=b;        b=c;    }    return a;}``

# G - 小白鼠排队

``#include<stdio.h>char color[1024][16]= {0};int n,t;int main(){    for(scanf("%d",&n); n--;)    {        scanf("%d",&t);        scanf("%s",color[t]);    }    for(int i=1000; i!=0; --i)        if(color[i][0])            printf("%s/n",color[i]);}``

# H - 单词替换

``#include<stdio.h>#include<string.h>char s[128][128];int cnt=0;int main(){    while(scanf("%s",s[cnt++])!=EOF);    for(int i=0; i<=cnt-4; ++i)        printf("%s ",               strcmp(s[i],s[cnt-3])?               s[i]:s[cnt-2]);}``

# I - 拦截导弹

``#include<stdio.h>int k,ans=0,h[32],f[32];int main(){    scanf("%d",&k);    for(int i=0; i!=k; ++i)    {        scanf("%d",&h[i]);        for(int j=f[i]=0; j!=i; ++j)            if(h[i]<=h[j]&&f[i]<f[j]+1)                f[i]=f[j]+1;        if(ans<f[i])ans=f[i];    }    printf("%d",ans+1);}``

# J - 玩游戏

``#include<stdio.h>#include<string.h>int k,n,a;int main(){    for(scanf("%d%d",&k,&n); n--;)    {        char s[9];        scanf("%s%d",s,&a);        if(!strcmp(s,"plus"))            k+=a;        if(!strcmp(s,"minus"))            k-=a;        if(!strcmp(s,"multiply"))            k*=a;    }    printf("%d",k);}``