You are viewing a single comment's thread. Return to all comments →
int main() { int k, i, j, s_size, t_size, count, br, nmod; char* s = (char *)malloc(512000 * sizeof(char)); char* t = (char *)malloc(512000 * sizeof(char)); scanf("%s", s); scanf("%s", t); scanf("%i", &k); s_size = strlen(s); t_size = strlen(t); br = 1; nmod = 0; for(i=count=0; i < s_size && br; i++){ if(s[i]==t[i]) count++; else br = 0; } if(s_size > t_size){ /* when length s greater than t / nmod = s_size - count; nmod = 2(nmod - t_size)+(s_size - t_size); }else if(s_size < t_size){ /* when length of s less than t / nmod = t_size - s_size; nmod = nmod + 2(s_size - count); }else{ /* when length of s equal to t */ nmod = 2 * (s_size - count); } nmod = abs(nmod); if(k < nmod) printf("No"); else printf("Yes");
return 0;
}
failed 2 cases
Seems like cookies are disabled on this browser, please enable them to open this website
Append and Delete
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
include
include
include
int main() { int k, i, j, s_size, t_size, count, br, nmod; char* s = (char *)malloc(512000 * sizeof(char)); char* t = (char *)malloc(512000 * sizeof(char)); scanf("%s", s); scanf("%s", t); scanf("%i", &k); s_size = strlen(s); t_size = strlen(t); br = 1; nmod = 0; for(i=count=0; i < s_size && br; i++){ if(s[i]==t[i]) count++; else br = 0; } if(s_size > t_size){ /* when length s greater than t / nmod = s_size - count; nmod = 2(nmod - t_size)+(s_size - t_size); }else if(s_size < t_size){ /* when length of s less than t / nmod = t_size - s_size; nmod = nmod + 2(s_size - count); }else{ /* when length of s equal to t */ nmod = 2 * (s_size - count); } nmod = abs(nmod); if(k < nmod) printf("No"); else printf("Yes");
}
failed 2 cases