---
# System prepended metadata

title: CK judge 作業紀錄

---

# CK judge 作業紀錄

### Lec4 Math Fanatic
```clike=
#include<stdio.h>

int main () {
    long long int n,a,sum=0;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a);
        sum+=a;

        if(sum%a==0)
            printf("%lld %lld\n",sum,a);
    }
}

```

### Lec4 Language model
```clike=
#include<stdio.h>

int main () {
    double p,ans=1.0;

    for(int i=0;i<5;i++)
    {
        scanf("%lf",&p);
        ans*=p;
        //printf("%f\n",ans);
    }
    printf("%.15lf",ans);
}

```
### Lec4 Capitalize English Name
```clike=
#include<stdio.h>
#include <string.h>

int main () {
    int n;
    char str[100000];
    scanf("%d\n",&n);
    fgets(str, 100000, stdin);
   // gets(str);
    //printf("%s",str);

    for(int i=0;i<strlen(str);i++)
    {
        if(i==0)
        {
            str[i]=(str[i]<='z'&&str[i]>='a'?str[i]-32 : str[i]);
            printf("%c",str[i]);
        }
        else if(str[i]==' ')
        {
            printf(" ");
            i++;
            if(i==strlen(str)) break;
            str[i]=(str[i]<='z'&&str[i]>='a'?str[i]-32 : str[i]);
            printf("%c",str[i]);
        }
        else if(str[i]==','||str[i]=='.'||str[i]==';')
        {
            printf("\n");
            i++;
            if(i==strlen(str)) break;
            str[i]=(str[i]<='z'&&str[i]>='a'?str[i]-32 : str[i]);
            printf("%c",str[i]);
        }
        else
        {
            if(str[i]<='Z')str[i]=str[i]+32;
            printf("%c",str[i]);
        }
    }

}

//Harry james potter;albus perCIval WulFric brian DUMbledore.

```
### Lec4 GPA calculator
>單個單個吃
```clike=
#include<stdio.h>

int main ()
{
    char x,y,m;
    int tem=1,total_c=0;
    double val[10]={0},ans=0;
    val[0]=4;
    val[1]=3;
    val[2]=2;
    while(1)
    {
        if(tem)
            scanf("%1c",&m);
        if(m=='\n') break;
        total_c+=m-'0';
        scanf("%1c",&x);
        scanf("%1c",&y);
        tem=1;
        if(y=='\n')
        {
            ans+=(m-'0')*val[x-'A'];
            //printf("%lf 1\n",m*val[x-'A']);
            break;
        }
        if(isdigit(y))
        {
            tem=0;
            ans+=(m-'0')*val[x-'A'];
            //printf("%lf 2\n",m*val[x-'A']);
            m=y;
        }
        else
        {
            double p= y=='+'?0.3:-0.3;
            ans+=(m-'0')*(val[x-'A']+p);
            //printf("%lf 3\n" ,m*(val[x-'A']+p));
        }
        //printf("%lf\n",ans);

    }
    printf("%.2lf",ans/total_c);
    return 0;
}
//2A+3B+2F1C-3C+1C+2C-

```
>字串處理 95%
```clike=
#include<stdio.h>
#include <string.h>

char str[1000000];
int main ()
{

    double ans=0;
    int total_c=0,val[10]= {0};
    val[0]=4;
    val[1]=3;
    val[2]=2;
    fgets(str,1000000,stdin);
    //printf("%d",strlen(str)-1);
    for(int i=0; i<strlen(str)-1; i++)
    {
        if(isdigit(str[i]))
        {

            //printf("%lf\n",ans);
            total_c+=str[i]-'0';
            if(str[i+2]=='\n'||isdigit(str[i+2]))
            {
                ans+=(str[i]-'0')*val[str[i+1]-'A'];
                i++;
            }
            else
            {
                float x=str[i+2]=='+'?0.3:-0.3;
                ans+=(str[i]-'0')*(val[str[i+1]-'A']+x);
                i+=2;
            }
        }


    }

    printf("%.2lf\n",ans/total_c);
}

//2A+3B+2F1C-3C+1C+2C-

//3C1B2F1F2F1B2C+

```