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. 怎么查找执行比较慢的sql语句-DBA给的建议

    1.使用sql动态视图 如下: b.text,a.total_worker_time,a.total_logical_reads,a.total_elapsed_time,execution_coun ...

  2. SQL Server 2008中的Service SID 介绍

    [介绍] 我们打开SQL Server 2008 Management Studio, 会发现有如下几个登录: NT SERVICE\ClusSvc, NT SERVICE\MSSQL$KATMAI和 ...

  3. Keepalived 安装与配置

    下载:http://www.keepalived.org/ what is keepalived? Keepalived is a routing software written in C. The ...

  4. JAVA-面向对象-继承

    继承   (关键字extends   ) (关键字 final 表示终态,在父类前加 final 则父类无法被继承,加在方法前则方法不能被重写或者覆盖,加在变量前则变量只能被赋值一次) 1.权限修饰符 ...

  5. Python学习总结8:文件模式及操作方法汇总

    文件操作之前需要文件保证文件存在,并且将文件open os.mknod("test.txt")        创建空文件 fp = open("test.txt" ...

  6. Ruby On Rails 在线学习好网站

    最好学习Ruby网站: https://ruby-china.org/    我的用户名:19920625lsg,  密码为最常用的 Ruby on Rails 教程 http://railstuto ...

  7. Java基础(60):Java打包生成Jar和Javadoc说明文档,以及在另外的工程中导入和使用自己的Jar

    一.Jar包的导出 1.在Package Explorer中选中项目,右键,点击“Export”   2.在弹出框一次选择Java-->JAR file,点击Next   3.在新弹出的窗口选择 ...

  8. paper 76:膨胀、腐蚀、开、闭运算——数字图像处理中的形态学

    膨胀.腐蚀.开.闭运算是数学形态学最基本的变换.本文主要针对二值图像的形态学膨胀:把二值图像各1像素连接成分的边界扩大一层(填充边缘或0像素内部的孔):腐蚀:把二值图像各1像素连接成分的边界点去掉从而 ...

  9. 夺命雷公狗ThinkPHP项目之----企业网站24之网站前台获取当前栏目和顶级栏目

    我们现在要实现的是取出网站当前栏目名称和顶级分类名称,如下所示: 列表页的和单页的不能总是写死的吧?? 我能就要想办法去让他变活的才可以解决问题噢,我们已经有了他的cate_id ,然后我们就可以通过 ...

  10. android 学习随笔二十二(小结)

    ADB进程 * adb指令 * adb install xxx.apk * adb uninstall 包名 * adb devices * adb start-server * adb kill-s ...