赞
踩
最近写的零零散散的,感觉这两天遇到的题对于短时间提升意义已经不大了,还是做简单题保持手感吧哎
#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; }*/
抽象,解题区法秒了()
#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; }
不是很明白,有没有大佬看明白题的意思了,先在这里放一下吧
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。