离散题目7
来源:互联网 发布:安捷伦数据采集器软件 编辑:程序博客网 时间:2024/05/29 21:17
离散题目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 51 2 3 4 5 6 7 8 9 101 3 5 7 8
Example Output
1010101100
Hint
Author
MeiK
此题相对来说很简单,只需要看出01的特点即可,在集合中有元素的位置即为1 无元素即为0
代码用时208ms,平台sdutoj
#include <iostream>#include<bits/stdc++.h>using namespace std;int main(){ int m,n; while(cin>>m>>n) { int a[100000] = {0}; int b[100000] = {0}; int c[100000] = {0}; for(int i = 0; i < m; i++) { cin>>a[i]; } for(int i = 0; i < n; i++) { cin>>b[i]; } int j = 0; for(int i = 0; i < n; i++) for(; j < m; j++) { if(a[j] == b[i]) { c[j]++; break; } } for(int i = 0; i < m; i++) { cout<<c[i]; } cout<<endl; } return 0;}
以下为校友BlessingXRY 桶排序——负坐标方法
用时 112ms 平台sdutoj
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;int main(){ int n, m, i, v, x[100004], vid[200004]; while(scanf("%d %d", &n, &m) != EOF) { for(i = 0; i < n; i++) { scanf("%d", &x[i]); vid[x[i]+100000] = 0; } for(i = 0; i < m; i++) { scanf("%d", &v); vid[v+100000] = 1; } for(i = 0; i < n; i++) { printf("%d", vid[x[i]+100000]); } printf("\n"); } return 0;}
阅读全文
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
- hacking exposed 作业
- NSError和NSException的几点说明
- Maven 常用命令
- 轻松制作自己的词云,向心爱的ta表达一下浪漫的心意吧
- JavaScript中的Object.defineProperty 函数
- 离散题目7
- ssm:简单整合开发框架
- 【笔记】一个实现多连接的蓝牙BLE的简单封装
- LoadRunnet_Run-time Settings 的详细说明
- JVM 通用参数调优
- USACO
- CPqD的参考资料
- 文章标题
- 进程与线程的一个简单解释