Code Festival D Compress numbers by cympfh

#include<stdio.h>
#include<string.h>
int main(){
  char s[20],t[20];
  for(;~scanf("%s%s",s,t);){
    int i=0,j,a=1,y,x;
    for(j=0;j<strlen(t);++j){
      y=t[j]-'0';
      if(i>=strlen(s)){a=0;break;}
      for(x=0;i<strlen(s);++i){x+=s[i]+2;if(x%10==y)break;}
      if(x%10!=y)a=0;
      ++i;
    }
    for(j=0;i<strlen(s);j+=s[i++]+2);
    if(a&&j%10)a=0;
    puts(a?"YES":"NO");
  }
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page