• UVaLive 7270 Osu! Master (统计)


    题意:给定 n 个元素,有的有一个值,如果是 S 那么是单独一个,其他的是一个,求从 1 开始的递增的数量是多少。

    析:那么S 是单独的,要统计上,既然是从 1 开始递增的,那么再统计 1 的数量即可。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    using namespace std ;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 3e5 + 5;
    const int mod = 1e9 + 7;
    const int dr[] = {0, 0, -1, 1};
    const int dc[] = {-1, 1, 0, 0};
    int n, m;
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    char s[10];
    
    int main(){
        int n;
        while(cin >> n){
            int ans = 0;
            for(int i = 0; i < n; ++i){
                cin >> s;
                if(s[0] == 'S') ++ans;
                else{
                    cin >> m;
                    if(1 == m)  ++ans;
                }
            }
            cout << ans << endl;
        }
        return 0;
    }
    
  • 相关阅读:
    goroutine
    golang package log
    golang单元测试
    golang 文件操作
    go递归打印指定目录下的所有文件及文件夹
    go语言切片作为函数参数的研究
    go数据类型之基本类型
    结束了
    codeforces358D Dima and Hares【dp】
    codeforces1081G Mergesort Strikes Back【期望dp+脑洞】
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5748601.html
Copyright © 2020-2023  润新知