CodeForces - 980A:Links and Pearls

39 篇文章 1 订阅

题目
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;
}

加油加油加油!!!!

在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值