当前位置:   article > 正文

【蓝桥杯第九场小白赛】(部分)

【蓝桥杯第九场小白赛】(部分)

最近写的零零散散的,感觉这两天遇到的题对于短时间提升意义已经不大了,还是做简单题保持手感吧哎

盖印章

#include <iostream>
using namespace std;
using LL=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    LL n,m,k;
    int cnt=0;
    cin>>n>>m>>k;
     for(int i=1;i<=n;i++)
       {
            string s;
            cin>>s;
            for(int j=0;j<m;j++)
            {
                if(s[j]=='1')
                cnt++;
            }
        }
         cout<<cnt-2*k<<' '<<3*k-cnt;
   
  return 0;
}
/*#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    
    int cnt=0;//统计1的个数
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            char c;
            cin>>c;
            if(c=='1')cnt++;
        }

    cout<<cnt-2*k<<' '<<3*k-cnt;//输出A和B的使用次数

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, k; cin >> n >> m >> k;
    ll x = 0;
    for (int i = 1; i <= n; i++) {
        string s; cin >> s;
        x += count(s.begin(), s.end(), '1');
    }
    cout << x - 2 * k << " " << 3 * k - x << endl;
    return 0;
}*/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62

抽象,解题区法秒了()

字典树考试

#include <bits/stdc++.h>
using namespace std;
long long a[34]={0};
long long sum=0;

int main()
{
    long long n;
    cin>>n;
    int c;
    for(long long  i=1;i<=n;i++)
    { 
        cin>>c;
        int k=0;
        int z=0;
        while(c)
        {
          k=c%2;
          if(k==1)
          a[z]++;
            z++;
            c/=2;
        }

    }
    for(int i=0;i<=31;i++)
    {
        if(a[i]>=2)
        sum+=(a[i]*(a[i]-1))/2;
    }
    cout<<sum<<endl;
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

不是很明白,有没有大佬看明白题的意思了,先在这里放一下吧

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/404968
推荐阅读
相关标签
  

闽ICP备14008679号