Please read the new rule regarding the restriction on the use of AI tools. ×

IbrahimElmourchidi's blog

By IbrahimElmourchidi, history, 6 years ago, In English

hello Every one ! i solved this problem https://codeforces.me/problemset/problem/785/A using c11 and after i solved the problem i saw others submissions to check if some one have a better solution and so i found a submission i cannot understand can some one please help , this is it :


#include <stdio.h> int t, n; main() { scanf("%d\n", &n); while (n--) { char s[9]; gets(s); t += "4!8D6<"[*s%7]-48; // this the line i cannot understand } printf("%d\n", t); }

and that was my submission :

#include<stdio.h>
int main()
{
    int a,i=0,c=0;
    scanf("%d",&a);
    char b[13];
    gets(b);
    for(i=0;i<a;i++)
    {
        gets(b);
        c+=( b[0]=='I'?20:b[0]=='C'?6:b[0]=='O'?8:b[0]=='D'?12:4 );
    }
    printf("%d",c);
}

Full text and comments »