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. 【译】typeof null的前世今生

        更新时间2013-11-05:为了更好的解释为什么typeof null的结果是object,我看了一下C代码的实现(译者注:Javascript源码).       在Javascript语 ...

  2. 选择Comparable接口还是Comparator

    个人理解: 如果我本身知道这个类的对象我要用来比较,那么就拿这个类实现Comparable接口(compareTo(Object o) 方法).如果我本身没有预料到我要比较这个类的对象,那么,我可以建 ...

  3. python高级编程技巧

    由python高级编程处学习 http://blog.sina.com.cn/s/blog_a89e19440101fb28.html Python列表解析语法[]和生成 器()语法类似 [expr  ...

  4. JMeter数据库性能测试

    要测试一个服务器的性能,客户要求向数据库内 1000/s(每插入一千条数据)的处理能力 前提条件:一个数据库:test   数据库下面有一张表:user   表中有两个字段:username.pass ...

  5. Bloom Filter 算法具体解释

    Bloom Filter 算法 Bloom filter是由Burton Bloom 在1970年提出的,其后在P2P上得到了广泛的应用.Bloom filter 算法可用来查询某一数据是否在某一数据 ...

  6. Oracle11g环境设置-windows环境

    新建环境变量(系统变量),变量名:ORACLE_HOME 变量值:E:\app\Administrator\product\11.2.0\dbhome_1 新建环境变量(系统变量),变量名:ORACL ...

  7. 小结: Async & Await

    新项目组用到Async & Await, 关于Await会不会新开不开线程,遇到什么情况会新开线程的问题网上查了很多资料都没看到直观的解释.现简单总结一下. 直接上代码: namespace ...

  8. 从反编译的角度去观察C#6.0

    1. 自动属性初始化 (Initializers for auto-properties) 1.1 C#6.0 之前的写法 public class FirstExperience { private ...

  9. 前台传来的文件通过流stream转成bytes 再把文件写入数据库 类型是blob

    //获取前台传来的文件 HttpFileCollection files = HttpContext.Current.Request.Files; Stream st = files[0].Input ...

  10. 《第一行代码》学习笔记5-活动Activity(3)

    1.Menu:让菜单得到展示的同时,不占用任何屏幕的空间. public boolean onCreateOptionsMenu(Menu menu){ getMenuInflater().infla ...