离散题目6
来源:互联网 发布:信息软件 编辑:程序博客网 时间:2024/06/09 22:13
离散题目6
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
bLue 最近忙于收集卡片,已知可收集的卡片一共有 n 种,每种卡片都有唯一的编号。 现在给出 bLue 已经收集到的 m 种卡片,你能告诉他剩下的没收集到的卡片都有什么吗?
Input
多组数据,到 EOF 结束(数据组数不超过 100)。
每组数据第一行输入 2 个整数 n (1 <= n <= 100), m (1 <= m <= n),分别表示卡片总的种类数和 bLue 已经收集到的种类数。
第二行输入 n 个从小到大给出的用空格分隔的整数,表示所有可收集卡片的编号。
第三行输入 m 个从小到大给出的用空格分隔的整数,表示 bLue 收集到的 m 种卡片的编号。
所有的编号都在 1~100 之间。
Output
对于每组数据,第一行输出一个整数,表示没有收集到的卡片有多少种,如果大于 0,则在下一行再按从小到大输出具体的编号。
Example Input
5 31 2 3 4 51 3 53 31 2 31 2 3
Example Output
22 40
Hint
第一组示例可以看作: U = {1, 2, 3, 4, 5},A = {1, 3, 5},答案即为 A 在 U 中的补集 C = {2, 4}。
Author
bLue
#include<bits/stdc++.h>using namespace std;int main(){ int m,n; while(cin>>m>>n) { int a[102] = {0}, b[102] = {0}; int s[102] = {0}; for(int i = 0; i < m; i++) { cin>>a[i]; } for(int i = 0; i < n; i++) { cin>>b[i]; } int v = 0; cout<<m-n<<endl; if(m-n != 0) { for(int j = 0; j < m; j++) { int flag = 0; for(int i = 0; i < n; i++) { if(b[i] == a[j]) { flag++; break; } } if(!flag) { s[v++] = a[j]; } } for(int i = 0; i < v; i++) { if(i != 0) cout<<" "; cout<<s[i]; } cout<<endl; } else continue; } return 0;}
阅读全文
0 0
- 3800-->离散题目6
- 离散题目6
- 离散题目6
- 离散题目6
- 离散题目6
- 离散题目6 求补集
- sdut-离散题目6
- 离散题目6(求补集)
- SDUT 3800 离散题目6
- 离散题目3
- 离散题目7
- sdut离散题目11
- sdut离散题目13
- sdut离散题目14
- 离散题目12
- 离散题目15
- 3799-->离散题目5
- 离散题目1
- android 耳机插拔流程
- 快速安装scrapy
- MSP430FR5969内存分配的问题
- shell正则表达式使用规则整理
- openssl命令 来自: http://man.linuxde.net/openssl
- 离散题目6
- 继承条件下构造方法的调用规则
- traffic server中的cache.config字段总结
- android自定义下拉刷新和上拉加载控件
- dedecms织梦后台出现502Bad Gateway的原因及解决办法
- 字典在 VLisp 中的应用
- MySQL批量SQL插入性能优化
- SylixOS 的system使用
- HttpURLConnection与HttpClient浅析