2016-08-19
UVA - 10050 Hartals
题目大意:给 T 个样例,连续 N 天,从周日开始,P 个队伍,每个队伍罢工的日子是所给队伍数字的倍数,多个队伍在同一天罢工只算一次,且周五周六不算,问罢工天数。
解题思路:模拟,循环,把罢工的日子算出来,到了那一天就 sum++ 。一旦有一组罢工过这天就结束,每周五周六跳过。
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char str1[500][100];
char str2[500][100];
int main() {
int n;
scanf("%d", &n);
while (n--) {
int N;
scanf("%d", &N);
getchar();
for (int i = 1; i <= N; i++)
gets(str1[i]);
for (int i = 1; i <= N; i++)
gets(str2[i]);
int x = N, y = N;
while ( x > 0 ) {
if ( !strcmp(str1[x], str2[y]) )
y--;
x--;
}
while ( y > 0 )
printf("%s\n", str2[y--]);
cout << endl;
}
return 0;
}