You are viewing a single comment's thread. Return to all comments →
Simple C Solution;
int main() {
int n, x, i, j, k; int a[27] = {0}; int f = 1; char s[100000]; fgets(s, sizeof(s), stdin); s[strcspn(s, "\n")] = 0; for (i = 0; i < 27; ++i) { a[i] = 0; } for (i = 0; s[i] != '\0'; ++i) { if (s[i] == s[i + 1]) { ++f; } else { if (f > a[s[i] - 'a']) { a[s[i] - 'a'] = f; } f = 1; } } if (f > a[s[i - 1] - 'a']) { a[s[i - 1] - 'a'] = f; } scanf("%d", &n); for (k = 0; k < n; ++k) { scanf("%d", &x); bool found = false; for (i = 1; i <= 26; ++i) { if (x % i == 0) { if (x / i <= a[i - 1]) { found = true; break; } } } if (found) { printf("Yes\n"); } else { printf("No\n"); } } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
Simple C Solution;
include
include
include
include
include
include
include
include
include
include
int main() {
}