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. (Factory method)工厂方法设计模式

    定义: 1.) 工厂方法模式是用来封装对象的创建,通过让子类来决定创建的对象是什么,来达到将对象创建的过程封装的目的: 2.) 定义了一个创建对象的接口,但由子类决定要实例的泪是哪一个.工厂方法让类把 ...

  2. Lintcode: Permutation Index II

    Given a permutation which may contain repeated numbers, find its index in all the permutations of th ...

  3. ASP.NET的一般处理程序对数据的基本操作

    TableList.ashx: <%@ WebHandler Language="C#" Class="TableList" %> using Sy ...

  4. 【IOS】3. OC 类声明和实现

    .h文件 @interface NewClassName:ParentClassName { 实例变量://基本类型和指针类型  不能在这里初始化,系统默认会初始化 系统初始化遵循: 实例变量类型   ...

  5. [原创]java WEB学习笔记90:Hibernate学习之路-- -HQL检索方式,分页查询,命名查询语句,投影查询,报表查询

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  6. jquery ajax 个人总结

    jquery : 在获取对象的时候,不要用dem的与jquery的混合写法,有的时候 用js获取到的对象 没有JQUERY对应的方法  会报一些不知道的错误.(即如果要使用jquery 就使用jque ...

  7. Java Web项目里开发获取上个页面连接地址的问题

    近期做的项目有个问题,就是需要获取上个页面连接地址,我用的IE浏览器,在用location.href连接到新地址的时候,在新地址页面用document.referrer的方法获取不到原地址,我测试了下 ...

  8. mtool安装

    先安装python pip.一种python包管理工具. 下面这篇文章讲的很详细.亲测可行. https://ruter.github.io/2015/12/03/Update-python/ git ...

  9. 夺命雷公狗---Thinkphp----13之前台的头尾分离和导航分离

    我们在实际的开发中往往网站的头尾都是分离开来的,而且tp这点做的也很人性化,他给我们留了一个include标签可以直接引入网站的头尾部分. 我们要做的网站当然也不例外,头尾一样分离开来: 我们先用浏览 ...

  10. 《C语言入门1.2.3—一个老鸟的C语言学习心得》—清华大学出版社炮制的又一本劣书及伪书

    <C语言入门1.2.3—一个老鸟的C语言学习心得>—清华大学出版社炮制的又一本劣书及伪书 [薛非评] 区区15页,有80多个错误. 最严重的有: 通篇完全是C++代码,根本不是C语言代码. ...