离散题目7
来源:互联网 发布:python 99乘法表思路 编辑:程序博客网 时间:2024/05/29 23:46
离散题目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
Hint
Author
#include<bits/stdc++.h>using namespace std;int a[100100],b[100100];int ser(int b[],int low,int high,int key){ if(low<=high) { int mid = (low+high)/2; if(b[mid]>key) { return ser(b,low,mid-1,key); } else if(b[mid]<key) { return ser(b,mid+1,high,key); } else { return 1; } } else { return 0; }}int main(){ int n,m; while(cin>>n>>m) { for(int i =0;i<n;i++) { scanf("%d",&a[i]); } for(int i = 0;i<m;i++) { scanf("%d",&b[i]); } sort(b,b+m); for(int i = 0;i<n;i++) { printf("%d",ser(b,0,m-1,a[i])); } cout<<endl; }}
阅读全文
0 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
- XML文档解析之JDOM解析
- JOptionPane
- iOS GCD的冰山一角
- php程序常用自检错误方法
- RecyclerView的简单使用
- 离散题目7
- Property 'X' not found on type entity.Customer错误原因分析
- 原生js封装ajax方法
- ### laravel--day2 路由
- 直方图匹配
- CentOS7下Java虚拟机监控
- MVC中Action过滤器(OnActionExecuting,OnActionExecuted,OnResultExecuting,OnResultExecued)
- [Leetcode] 213. House Robber II 解题报告
- RTMP协议分析——神文,非常详细