Codeforces Round #688 (Div. 2) A.Cancel the Trains(800)

codeforces 1453 A.Cancel the Trains
在这里插入图片描述
在这里插入图片描述
思路分析:
经典签到题,最后的意思大概是,横纵出发的号一样的话,才会相撞

AC代码:

#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 110;
 
int a[N];
 
int main() {
    
    
    int t;
    cin >> t;
    while (t--) {
    
    
        int n, m;
        cin >> n >> m;
        int res = 0;
        int num;
        for (int i = 0; i < n; i++)
            cin >> a[i];
        while (m--) {
    
    
            cin >> num;
            for (int i = 0; i < n; i++)
                if(num == a[i]) {
    
    
                    res++;
                    break;
 
                }
        }
        cout << res << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_45654671/article/details/113047657