离散题目10
2017-05-24 20:17
183 查看
离散题目10
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
给定一个数学函数F和两个集合A,B,写一个程序来确定函数是满射。 如果每个可能的像至少有一个变量映射其上(即像集合B中的每个元素在A中都有一个或一个以上的原像),或者说值域任何元素都有至少有一个变量与之对应,那这个映射就叫做满射。
Input
多组输入直到文件结束,对于每组输入,第一行先输入一个n(A集合里的元素个数),m(B集合里的元素个数),k(F数学函数关系的条数)。
0 < n,m < 10000, 0 < k < n;
第二行输入有n个元素,分别为a1到an;
第三行输入有m个元素,分别为b1到bn;
接下来输入有k行,分别为集合A到B的关系
Output
(一组答案占一行)
当满足满射关系时输出Yes。
不满足关系时输出No。
Example Input
5 3 5
1 3 5 7 8
2 5 6
1 2
3 6
5 5
7 2
8 6
Example Output
Yes
Think:判断是不是集合B当中的元素都有A集合中的元素与之对应
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
给定一个数学函数F和两个集合A,B,写一个程序来确定函数是满射。 如果每个可能的像至少有一个变量映射其上(即像集合B中的每个元素在A中都有一个或一个以上的原像),或者说值域任何元素都有至少有一个变量与之对应,那这个映射就叫做满射。
Input
多组输入直到文件结束,对于每组输入,第一行先输入一个n(A集合里的元素个数),m(B集合里的元素个数),k(F数学函数关系的条数)。
0 < n,m < 10000, 0 < k < n;
第二行输入有n个元素,分别为a1到an;
第三行输入有m个元素,分别为b1到bn;
接下来输入有k行,分别为集合A到B的关系
Output
(一组答案占一行)
当满足满射关系时输出Yes。
不满足关系时输出No。
Example Input
5 3 5
1 3 5 7 8
2 5 6
1 2
3 6
5 5
7 2
8 6
Example Output
Yes
Think:判断是不是集合B当中的元素都有A集合中的元素与之对应
#include <stdio.h> #include <string.h> int a,b,c,d,e[10010],f[10010],s[10010]; int main(){ int n,m,x; while(~scanf("%d%d%d",&n,&m,&x)){ memset(e,0,sizeof(e)); memset(f,0,sizeof(f)); memset(s,0,sizeof(s)); for (int i=0;i<n;i++){ scanf("%d",&a); e[a]++; } for (int i=0;i<m;i++){ scanf("%d",&b); f[b]++; } int count=0; for (int i=0;i<x;i++){ scanf("%d%d",&c,&d); if (e[c]>0&&f[d]>0){ s[d]++; if (s[d]==1){ count++; } } } if (count==m){ printf("Yes\n"); } else{ printf("No\n"); } } return 0; }
相关文章推荐
- 离散题目10(判断是否为满射函数 )
- SDUT 3804 离散题目10
- 离散题目10
- 离散题目10
- 离散题目10 判断满射
- 离散题目10
- sdut-离散题目10
- 离散题目10
- 离散题目14 判断是否对称
- 离散题目13
- 离散题目15
- sdut-l离散题目2
- sdut-离散题目15
- 剑指offer 07-10 斐波那契数列类型题目的动态规划解题方法(递归方法)
- 2014 Multi-University Training Contest 10 部分题目解题报告
- 10 25日考试 数学题目练习 斐波拉契 打表
- 题目1208:10进制 VS 2进制
- google面试题目10
- 蓝桥杯题目10矩阵翻硬币
- 离散题目5