980A - Links and Pearls - CodeForces Solution


implementation math *900

Please click on ads to support us..

Python Code:

necklace = input()
 
if necklace.count('o') == 0:
    print("YES")
elif necklace.count('-') % necklace.count('o') == 0:
    print("YES")
else:
    print("NO")

C++ Code:

#include<bits/stdc++.h>
#define int long long 
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define pre(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
const int INF=0x3f3f3f3f,mod=1e9+7;

void solve(){
	string s;
	cin>>s;
	int x=0,y=0;
	rep(i,0,s.size()-1){
		if(s[i]=='-')x++;
		else y++;
	}
	if(x==0||y==0)cout<<"YES";
	else if(x%y==0)cout<<"YES";
	else cout<<"NO";
}

signed main(){ 
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	solve();
    return 0;
}
/*
2 0
1 3

*/
	 	  	  						  	 	     			 	 	


Comments

Submit
0 Comments
More Questions

1728D - Letter Picking
792B - Counting-out Rhyme
1195A - Drinks Choosing
5D - Follow Traffic Rules
1272A - Three Friends
1632D - New Year Concert
1400D - Zigzags
716C - Plus and Square Root
412A - Poster
844B - Rectangles
1591A - Life of a Flower
1398C - Good Subarrays
629A - Far Relative’s Birthday Cake
1166A - Silent Classroom
1000B - Light It Up
218B - Airport
1463B - Find The Array
1538C - Number of Pairs
621B - Wet Shark and Bishops
476B - Dreamoon and WiFi
152C - Pocket Book
1681D - Required Length
1725D - Deducing Sortability
1501A - Alexey and Train
721B - Passwords
1263D - Secret Passwords
1371B - Magical Calendar
1726E - Almost Perfect
1360C - Similar Pairs
900A - Find Extra One