Doubles
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 19954   Accepted: 11536

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 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.

Sample Input

1 4 3 2 9 7 18 22 0
2 4 8 10 0
7 5 11 13 1 3 0
-1

Sample Output

3
2
0
/*
题意简单,找有几对倍数
*/
#include <cstdio>
#include <string.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define WW freopen("output.txt","w",stdout)
using namespace std;
const int Max=110;
int Arr[Max];
bool vis[110];
int main()
{
int data;
int top;
while(scanf("%d",&Arr[0])&&Arr[0]!=-1)
{
memset(vis,false,sizeof(vis));
vis[Arr[0]]=true;
top=1;
while(1)
{
scanf("%d",&data);
if(!data)
break;
Arr[top++]=data;
vis[data]=true;
}
sort(Arr,Arr+top);
int sum=0;
for(int i=0;i<top;i++)
{
if(Arr[i]>50)
{
break;
}
if(vis[Arr[i]*2])
{
sum++;
}
}
printf("%d\n",sum); }
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Doubles 分类: POJ 2015-06-12 18:24 11人阅读 评论(0) 收藏的更多相关文章

  1. Color Me Less 分类: POJ 2015-06-10 18:24 11人阅读 评论(0) 收藏

    Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31693   Accepted: 15424 D ...

  2. c++map的用法 分类: POJ 2015-06-19 18:36 11人阅读 评论(0) 收藏

    c++map的用法 分类: 资料 2012-11-14 21:26 10573人阅读 评论(0) 收藏 举报 最全的c++map的用法 此文是复制来的0.0 1. map最基本的构造函数: map&l ...

  3. Rebuild my Ubuntu 分类: ubuntu shell 2014-11-08 18:23 193人阅读 评论(0) 收藏

    全盘格式化,重装了Ubuntu和Windows,记录一下重新配置Ubuntu过程. //build-essential sudo apt-get install build-essential sud ...

  4. POJ 1068 AC 2014-01-07 15:24 146人阅读 评论(0) 收藏

    POJ的题目都是英文的,所以,,,还是直接贴代码吧 #include<stdio.h> int main(){ int x,y,z; int n,nm,max; scanf("% ...

  5. 由 argv引出的main参数 分类: C/C++ 2014-11-08 18:00 154人阅读 评论(0) 收藏

    我们经常用的main函数都是不带参数的.因此main 后的括号都是空括号.实际上,main函数可以带参数,这个参数可以认为是 main函数的形式参数.C语言规定main函数的参数只能有两个, 习惯上这 ...

  6. Bzoj 1036 树的统计 分类: ACM TYPE 2014-12-29 18:55 72人阅读 评论(0) 收藏

    Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. Q ...

  7. Ubuntu vim+ ctags(包含系统函数) + taglist 配置 分类: vim ubuntu 2015-06-09 18:19 195人阅读 评论(0) 收藏

    阅读大型代码,我们经常需要打开很多的代码文件,搜索各种定义.windows下用惯了ide的朋友,转战Linux的时候可能会觉得很难受,找不到合适的阅读工具.其实万能的vim就可以实现.下面介绍一下vi ...

  8. 跨服务器修改数据 分类: SQL Server 2014-08-21 21:24 316人阅读 评论(0) 收藏

     说明: 两个服务器: 192.168.0.22   A 192.168.0.3     B 数据库备份在A上 数据库在B上 在A上写: exec sp_addlinkedserver   'ITSV ...

  9. mount命令以及mount ntfs硬盘权限权限与显示的问题 分类: shell ubuntu 2014-11-08 18:29 148人阅读 评论(0) 收藏

    sudo mount -t 文件系统类型 -o 可设置选项 设备路经 访问路经 #常用文件类型如下: iso9660 光驱文件系统, vfat fat/fat32分区, ntfs ntfs分区, sm ...

随机推荐

  1. TPageControl组件

    TPageControl的功能是创建多个Dialog页,而这些重叠的每一个页Dialog就是通过TTabSheet对象实现的

  2. configuring tortoise git and vs code.

    Preparation, SSH keygen: $ git config --global user.name "calos" $ git config --global use ...

  3. Java基础(63):正则表达式的运用

    Java 正则表达式 正则表达式定义了字符串的模式. 正则表达式可以用来搜索.编辑或处理文本. 正则表达式并不仅限于某一种语言,但是在每种语言中有细微的差别. Java正则表达式和Perl的是最为相似 ...

  4. Java基础(44):ArrayList使用详解

    1.什么是ArrayList ArrayList就是传说中的动态数组,用MSDN中的说法,就是Array的复杂版本,它提供了如下一些好处:    a.动态的增加和减少元素    b.实现了IColle ...

  5. 。。。Hibernate 查询数据 事务管理。。。

    在Hibernate中,查询数据的时候,可能会需要事务的管理,为什么呢?因为在查询数据库的时候,Hibernate将数据从数据库里面查询出来之后,会先把数据放入Hibernate的session缓存里 ...

  6. .net 网站预编译命令

    aspnet_compiler -v /Aspnet  -p "C:\inetpub\wwwroot\a"  C:\inetpub\wwwroot\a2 /Aspnet   iis ...

  7. Oracle游标总结

    1.声明游标 declare teacher_id ); teacher_name ); teacher_title ); teacher_sex ); cursor teacher_cur is ; ...

  8. 夺命雷公狗---Thinkphp----7之栏目配合Model的增删改查

    我们首先来写一个查: public function lists(){ $type = M('Type')->select(); $this -> assign('type',$type) ...

  9. LDA-math-LDA 文本建模

    http://cos.name/2013/03/lda-math-lda-text-modeling/ 5. LDA 文本建模 5.1 游戏规则 对于上述的 PLSA 模型,贝叶斯学派显然是有意见的, ...

  10. [ThinkPHP] 输出、模型的使用

    # # ThinkPHP 3.1.2 输出和模型使用 # 讲师:赵桐正 微博:http://weibo.com/zhaotongzheng   本节课大纲: 一.ThinkPHP 3 的输出      ...