离散题目7
来源:互联网 发布:淘宝首页海报是指什么 编辑:程序博客网 时间:2024/05/20 03:04
离散题目7
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
DaYu在新的学习开始学习新的数学知识,一天DaYu学习集合的时候遇到一个问题,他有一个集合A和A的子集B,他想用一个二进制串表示集合B。
Input
多组输入,每组的第一行有两个数n,m,(0< m < n < 10^5).
第二行输入n个数表示集合A,第三行输入m个数表示集合B,|data_i|< 10^5
Output
输出一个01字符串表示集合B
Example Input
10 5
1 2 3 4 5 6 7 8 9 10
1 3 5 7 8
Example Output
1010101100
Think:如果集合A的元素在集合B中,那么相应下标的位置输出1,否则输出0
#include <stdio.h>#include <stdlib.h>#include <string.h>struct node{ int Q; int W;}a[300010];int c[300010];int main(){ int n,m,b; while(~scanf("%d %d",&n,&m)) { for(int i=0;i<=300000;i++) { a[i].Q=0; a[i].W=0; } for(int i=0;i<n;i++) { scanf("%d",&c[i]); } for(int i=0;i<m;i++) { scanf("%d",&b); a[b+100010].W=1; } for(int i=0;i<n;i++) { if(a[c[i]+100010].W==1) printf("1"); else printf("0"); } printf("\n"); } return 0;}
阅读全文
1 0
- 离散题目7
- 离散题目7
- SDUT-离散题目7
- 离散题目7
- 离散题目7
- 离散题目7
- sdut-离散题目7
- 离散题目7
- 离散题目7-二进制串
- SDUT 3801 离散题目7
- 离散题目7 二进制串表示集合
- 离散题目7(输出转换)
- 离散题目3
- sdut离散题目11
- sdut离散题目13
- sdut离散题目14
- 离散题目12
- 离散题目15
- [置顶] Spark2.1.0文档:Spark Streaming 编程指南(下)-性能调优和容错语义
- 安装TestNG在eclipse中的插件
- mongodb
- zTree简单使用和代码结构
- [机器学习]week3编程作业:Logistic Regression
- 离散题目7
- HDOJ 1024 Max Sum Plus Plus
- Android Shape 的使用
- 详解Java中的XML解析
- Android相机基础介绍
- 面试感悟
- UI自动测试中遇到
- 安卓 身份证键盘 输入限制
- HDU1176(二维动态规划)