奶牛体操
思路分析
代码实现
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
unordered_map<string,int> cnt;
const int N = 30;
int a[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int k,n;cin>>k>>n;
for(int i=0;i<k;i++){
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
string key = to_string(a[i]) + " " + to_string(a[j]);
cnt[key]++;
}
}
}
int ans=0;
for(auto x:cnt){
if(x.second==k) ans++;
}
cout<<ans;
return 0;
}
同类题型
视频讲解
⬅️ 哞叫时间2 🏠 00-刷题理模型 ➡️ 奶牛体检
💬 评论