[Codeforces Round #164 (Div. 2)]A. Games

地址:http://codeforces.com/contest/268/problem/A

枚举的同时计数...

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 int n,h[30],a[30];
 6 
 7 int main()
 8 {
 9     ios::sync_with_stdio(false);
10     int con=0;
11     cin>>n;
12     for(int i=0;i<n;i++)
13     {
14         cin>>h[i]>>a[i];
15     }
16     for(int i=0;i<n;i++)
17     {
18         for(int j=0;j<n;j++)
19         {
20             if(i==j) continue;
21             if(h[i]==a[j]) con++;
22         }
23     }
24     cout<<con;
25     return 0;
26 }

 

posted @ 2013-01-29 17:31  tjsuhst  阅读(145)  评论(0编辑  收藏  举报