Title:
With pearls and threads, ask if it can be rearranged so that the number of threads between adjacent pearls is equal.
Ideas:
First of all, if the pearl is 0 or the line is 0, then the conditions are met;
Secondly, if the number of pearls is greater than the number of threads, then the condition is definitely not met;
Then, if the number of lines is divisible by pearls, then the condition is satisfied, otherwise it is not.
Code:
#include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { string s; cin >> s; int l = 0,p = 0; for (int i = 0;i < s.size();i++) { if (s[i] == 'o') p++; else l++; } if (l == 0 || p == 0) puts("Yes"); else { if (p > l) puts("no"); else if (l % p == 0) puts("yes"); else puts("no"); } return 0; }