zoukankan      html  css  js  c++  java
  • Codeforces Round #480 (Div. 2) A. Links and Pearls

    题目地址:http://codeforces.com/contest/980/problem/A

    官方题解:

    我的理解:o表示珍珠,-表示链子,给一串字符串你可以任意重组这条项链(不能删去),判断这条项链两个珠子之间的链子个数能否相同。

    方法:字符串遍历,统计珍珠和链子的数量。珠子如果是0是YES,链子能整除珠子也是YES,其他都是NO。

     1 #include<cstdio>
     2 #include<cmath>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<string>
     6 #include<iostream>
     7 #include<map>
     8 #include<vector>
     9 #include<set>
    10 #include<queue>
    11 using namespace std;
    12 char s[105];
    13 int main()
    14 {
    15     scanf("%s", s);
    16     int len = strlen(s);
    17     int zhu = 0;
    18     int xian = 0;
    19     for (int i = 0; i<len; i++)
    20     {
    21         if (s[i] == 'o')
    22             zhu++;
    23         else
    24             xian++;
    25     }
    26     if (zhu == 0)
    27         printf("YES
    ");
    28     else
    29     {
    30         if (xian%zhu == 0)
    31             printf("YES
    ");
    32         else
    33             printf("NO
    ");
    34     }
    35     return 0;
    36 }
  • 相关阅读:
    Integer to English Words
    Word Ladder II
    Word Ladder
    Distinct Subsequences
    Interleaving String
    Scramble String
    【转】ROC和AUC介绍以及如何计算AUC
    Minimum Size Subarray Sum
    Minimum Window Substring
    Edit Distance
  • 原文地址:https://www.cnblogs.com/Tangent-1231/p/9013111.html
Copyright © 2011-2022 走看看