Doubles
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 18824   Accepted: 10846

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

Source

Mid-Central USA 2003
#include <iostream>
#include<cstring>
using namespace std; int main()
{
int a[];
cin>>a[];
while(a[]!=-)
{
int n =;
int ans = ;
for(;;n++)
{
cin>>a[n];
if(a[n]==)
break;
}
for(int i=;i<n-;i++)
{
for(int j=i+;j<n;j++)
if(a[i]*==a[j]||a[i]==a[j]*)
ans++;
}
cout<<ans<<endl;
memset(a,,sizeof(a));
cin>>a[];
}
return ;
}

poj1552的更多相关文章

随机推荐

  1. Corrupted MAC on input

    Corrupted MAC on input Incorrect MAC received on packet

  2. Qt Creator中,include路径包含过程(或如何找到对应的头文件)

    Qt Creator中,include路径包含过程(或如何找到对应的头文件) 利用Qt Creator开发程序时,需要包含利用#include来添加头文件. 大家都知道,#include <&g ...

  3. text-overflow简单使用

    text-overflow属性配合overflow才有效果,还记得把文字强制一行显示,如下代码: <!DOCTYPE html> <html lang="zh-cn&quo ...

  4. junit4测试 Spring MVC注解方式

    本人使用的为junit4进行测试 spring-servlet.xml中使用的为注解扫描的方式 <?xml version="1.0" encoding="UTF- ...

  5. 为iPhone6设计自适应布局(一)

    译者的话:本文是自适应布局的巩固篇,所以对布局约束的添加操作步骤等没有详细的说明.如果看着吃力的话请先移步Swift自适应布局(Adaptive Layout)教程. Apple从iOS6加入了Aut ...

  6. 《javascript设计模式》读书笔记四(单例模式)

    1.单利模式简单介绍 在<设计模式>中单利模式是一种比較简单的模式,定义例如以下: 确保某一个类仅仅有一个实例,并且自行实例化并向整个系统提供这个实例. 在javascript中则将代码组 ...

  7. UIWindow in iOS

    这篇文章,我将分享对UIWindow我所知道的东西. keyWindow 一个应用能够有许多UIWindow,“The key window”是其中一个,被设计用来接受键盘和其他与点击无关的事件.一个 ...

  8. easyUI的datagrid控件日期列不能正确显示Json格式数据的解决方案

    EasyUI是一套比较轻巧易用的Jquery控件,在使用过程中遇到一个问题,它的列表控件——datagrid, 在显示日期列的时候,由于后台返回给页面的数据是Json格式的,其中的日期字段,在后台是正 ...

  9. Js字面变量,定义问题

    Js字面变量.浏览器的版本问题:

  10. asp.net 如何改变GridView搜索出来关键字的颜色?就像百度似的,我获得的是一个集合,改变集合中关键字的集合

    输入“产量”查询,将“产量”拆分,产.量 string strColNameCnDt = string.Empty;            for (int j = 0; j < dtTemp. ...