8 solutions

  • 0
    @ 2024-12-6 21:49:48
    #include<stdio.h>
    
    int main()
    {
        int n,i,j,k,L;
        char l,id[18];
        scanf("%d \n", &n);
      
        for(i=0;i<n;i++)
        {
            for (j = 0; j < 17; j++)
            {
                scanf("%c", &id[j]);
            }
         scanf("%c \n", &l);
         if(l=='X')
         {
             L = 10;
         }
         else{L=l-'0';}
        int sum = 0,t=16,prime;
       while (t>=0)
        {
            prime = id[t] - '0';
            
            switch (t)
            {
            case 16:sum += (2 * prime); break;
            case 15:sum += (4 * prime); break;
            case 14:sum += (8 * prime); break;
            case 13:sum += (5 * prime); break;
            case 12:sum += (10 * prime); break;
            case 11:sum += (9 * prime); break;
            case 10:sum += (7 * prime); break;
            case 9:sum += (3 * prime); break;
            case 8:sum += (6 * prime); break;
            case 7:sum += (1 * prime); break;
            case 6:sum += (2 * prime); break;
            case 5:sum += (4 * prime); break;
            case 4:sum += (8 * prime); break;
            case 3:sum += (5 * prime); break;
            case 2:sum += (10 * prime); break;
            case 1:sum += (9 * prime); break;
            case 0:sum += (7 * prime); break;
            }
            t--;
        }
        int M=sum%11;
        switch (M)
        {
        case 0:k=1; break;
        case 1:k=0; break;
        case 2:k=10; break;
        case 3:k=9; break;
        case 4:k = 8; break;
        case 5:k = 7; break;
        case 6:k = 6; break;
        case 7:k = 5; break;
        case 8:k = 4; break;
        case 9:k = 3; break;
        case 10:k = 2; break;
        }
        if(k==L)
        {
        printf("True\n");
        }
        else{ printf("False\n");}
        }
        return 0;
    }
    

    C语言手搓版

    Information

    ID
    41
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    1800
    Accepted
    230
    Uploaded By