hdu 1303 Doubles
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=1303
Doubles
Description
As part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list are twice some other item in the same list. You will need a program to help you with the grading. This program should be able to scan the lists and output the correct answer for each one. For example, given the list 
1 4 3 2 9 7 18 22
your program should answer 3, as 2 is twice 1, 4 is twice 2, and 18 is twice 9.
Input
The input file will consist of one or more lists of numbers. There will be one list of numbers per line. Each list will contain from 2 to 15 unique positive integers. No integer will be larger than 99. Each line will be terminated with the integer 0, which is not considered part of the list. A line with the single number -1 will mark the end of the file. The example input below shows 3 separate lists. Some lists may not contain any doubles.
Output
The output will consist of one line per input list, containing a count of the items that are double some other item.
SampleInput
1 4 3 2 9 7 18 22 0
2 4 8 10 0
7 5 11 13 1 3 0
-1
SampleOutput
3
2
0
刷些水题打发时间。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::set;
using std::map;
using std::pair;
using std::vector;
using std::multiset;
using std::multimap;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
const int Max_N = ;
typedef unsigned long long ull;
set<int> res;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int v;
while (~scanf("%d", &v) && ~v) {
int sum = ;
res.insert(v);
while (~scanf("%d", &v) && v) res.insert(v);
tr(res, ite) {
if (res.find(*ite << ) != res.end()) sum++;
}
printf("%d\n", sum);
res.clear();
}
return ;
}
hdu 1303 Doubles的更多相关文章
- HDOJ 1303 Doubles(简单题)
		Problem Description As part of an arithmetic competency program, your students will be given randoml ... 
- 转载:hdu 题目分类 (侵删)
		转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ... 
- HDU——PKU题目分类
		HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ... 
- [转] HDU 题目分类
		转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ... 
- HDU ACM 题目分类
		模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ... 
- HDU 5643 King's Game 打表
		King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ... 
- hdu  分类
		HDU分类 http://www.cnblogs.com/ACMan/archive/2012/05/26/2519550.html#2667329 努力A完.方便自己系统A题 不断更新中...... ... 
- HDOJ 2111. Saving HDU 贪心 结构体排序
		Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ... 
- 【HDU 3037】Saving Beans Lucas定理模板
		http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ... 
随机推荐
- IIS 发布MVC 提示开启目录浏览
			修改应用池 托管管道模式为 集成 
- imp-00002 无法打开。。
			路径错了无疑 文件名少了个字符无疑 文件名错了无疑 
- ctags 文章
			http://blog.csdn.net/wuziqi4/article/details/1709722 
- Solarwinds Orion NPM实战视频演示
			Orion Network Performance Monitor是全面的带宽性能监控和故障管理软件,能监控并收集来自路由器.交换机.服务器和其他SNMP设备中的数据,您可以直接从Web浏览器上观察您 ... 
- hql语句关联查询(select new )
			在 new bean()中,对象里要有其构造方法,查询参数必须是构造方法中的参数,get set也要同步 类似于 String hql= "select new A(a.id, a.na ... 
- docker1.12在cento7里的跨多主机容器网络
			docker1.12在cento7里的跨多主机容器网络 
- Qt 信号和槽函数
			信号和槽是一种高级接口,应用于对象之间的通信,它是 QT 的核心特性.当某个信号被发射,就需要调用与之相绑定的槽函数.这与Windows下的消息机制类似,消息机制是基于回调函数.一个回调即是一个函数的 ... 
- PHP实现物流查询(通过快递网API实现)
			物流查询实现 引 言:目前快递公司太多了,不可能一个一个去申请api查询.这个时候,就可以通过合作,找一些中间商合作.我试了两家,一家是快递100,一家是快递网. 他们都需要申请key.但是快递100 ... 
- Linux之文件系统的简单操作
			df:列出文件系统整体硬盘使用量 将容量以易读方式显示: [root@zkero ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/s ... 
- Android IOS WebRTC 音视频开发总结(六四)-- webrtc能走多远我不知道,但这个市场真实存在
			本文主要总结目前都有哪些使用场景用到webrtc,文章最早发表在我们的微信公众号上,详见这里, 欢迎关注微信公众号blackerteam,更多详见www.blackerteam.com webrtc只 ... 
