Links and Pearls CodeForces - 980A (水题)

A. Links and Pearls
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

The only line of input contains a string ss (3|s|1003≤|s|≤100), representing the necklace, where a dash '-' represents a link and the lowercase English letter 'o' represents a pearl.

Output

Print "YES" if the links and pearls can be rejoined such that the number of links between adjacent pearls is equal. Otherwise print "NO".

You can print each letter in any case (upper or lower).

Examples
input
Copy
-o-o--
output
Copy
YES
input
Copy
-o---
output
Copy
YES
input
Copy
-o---o-
output
Copy
NO
input
Copy
ooo
output
Copy
YES

题意:给出一个字符串,'o'代表珍珠,'-'代表线,问,这些珍珠和线能否重新组成一条珍珠项链,使得珍珠与珍珠之间的间隔相等。

思路:求一下珍珠的个数,和线的个数,然后看是否可以整除即可,不过需要特判的是,珍珠为0或线为0都算可以emmmm真奇怪。

#include "iostream"
using namespace std;
int main()
{
    int x=0,y=0;
    char s[105];
    cin>>s;
    for(int i=0;s[i];i++) {
        if (s[i]=='o') x++;
        else y++;
    }
    if (x==0||y==0)
        cout<<"yes"<<endl;
    else{
        if (x>y) cout<<"no"<<endl;
        else if (y%x==0) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值