题目
A necklace can be described as a string of links (’-’) and pearls (‘o’), with the last link or pearl connected to the first one.
You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as you like, but you can’t throw away any parts.
Can you make the number of links between every two adjacent pearls equal? Two pearls are considered to be adjacent if there is no other pearl between them.
Note that the final necklace should remain as one circular part of the same length as the initial necklace.
题意
给一个环形的手链,你可以任意移动链和珠子的位置。
是否可以得到一个每个珠子之间的链条数相同的手链?
思路
水水水~
如果珠子/链条的数量为0就一定可以。
链条的数量是珠子数量的整数倍时也可以。
伊丽莎白!
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a=0,b=0;
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
if(s[i]=='o')
a++;
else
b++;
}
if(a==0||b==0||b%a==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
加油加油加油!!!!