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 ...
随机推荐
- BZOJ1996 合唱队 区间DP
OJ地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1996 设dp(i,j,k)代表在理想结果中[i,j]段最后添加的是i或j(k=0or1) ...
- IBM Tivoli NetView网管软件实战
广大网络管理者需要一款包括网络监控故障处理的一个集成网络管理平台,本文根据作者多年实践提出的基于IBM Tivoli Netview的综合网络管理平台,IBM Tivoli与Cisco一直保持着良好的 ...
- APUE第五章:标准IO库
5.2流和file对象 #include <wchar.h> int fwide(FILE *fp, int mode); Returns: positive if stream is w ...
- adb调试命令详解-2016.02.01
adb(Android Debug Bridge),调试桥可以让设备的调试监测过程在远端进行,而不必在运行实际运行应用的设备上,方便调试的输出. 1 命令详解 a 查看帮助信息 adb ...
- VBS创建数据库
'创建数据库'参数:strDBPath 字符串型 数据库文件的完整路径Sub CreateDataBase(strDBPath)Dim catObjSet catObj = CreateObject( ...
- 深入了解Qt(三)之元signal和slot
深入了解Qt主要内容来源于Inside Qt系列,本文做了部分删改,以便于理解.在此向原作者表示感谢! 在Qt 信号和槽函数这篇文章中已经详细地介绍了信号和槽的使用及注意事项.在这里对其使用方面的知识 ...
- 用verilog模拟DDS产生正弦波信号
前言: DDS:直接数字频率合成,正弦波0-2pi周期内,相位到幅度是一一对应的(这里我们使用放大后的整数幅度). 主要思路: 个人理解,FPGA不擅长直接做数字信号计算,那样太占用片上逻辑资源,所以 ...
- Magento后台界面全局样式修改之——font-weight
路径: \app\design\adminhtml\Magento\backend\web\app\setup\styles\less\lib\_variables.less
- 使用jquery时弹出[object HTMLImageElement]问题
本打算写一个轮播图,但是获取到图像后想改变图片地址,却jq方法各种不能实现,开始以为是jq文件弄错了,用百度的cdn试了下还是报错. 于是开始了alert调试. 我是用的jquery获取类 var a ...
- sed的惯常用法
1:注释掉某一行这个经常会遇到的,把配置文件里某一行注释掉.让他不起作用.sed -i -e ’121 s/^/#/’ /usr/local/apache2/conf/httpd.conf上面一行命令 ...