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. 上传图片代码(chuantouxiang.php+touxiangchuli.php)

    <body> <form action="touxiangchuli.php" method="post" enctype="mul ...

  2. git hub 资料汇总

    tobecrazy  Selenium automation test framework    https://github.com/tobecrazy/Demo Smartphone Test F ...

  3. windows 杀进程

    selenium自动化时,会启动chromedriver.exe,每次运行一次,就多启动一个,执行多次就会拖慢系统.如下批处理命令,可以批量杀掉进程 tasklist |find "chro ...

  4. 操作系统——IO缓存技术

    一.为什么引入缓存技术 为了解决cpu速度和外部设备速度不匹配的问题. 降低了io对cpu的中断的次数.每进行一次IO设备的时间都非常长,所以把数据先放入缓冲区,再进行IO操作. 二.缓冲技术的实现 ...

  5. string之substring的用法

    package com.j1; public class StringTest1 { public static void main(String[] args) { String s =" ...

  6. 转载--DEV GridControl 的一些基本操作

    1. 如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 2. 如何新增一条记录 (1).gridView.Ad ...

  7. 掌握jQuery插件开发,这篇文章就够了

    ---恢复内容开始--- 在实际开发工作中,总会碰到像滚动,分页,日历等展示效果的业务需求,对于接触过jQuery以及数据jQuery使用的人来说,首先想到的肯定是寻找现有的jQuery插件来满足形影 ...

  8. 不安装开发环境,查看logcat日志

    #公司的测试终于想到要看 android 的日志.安装开发环境太麻烦了,这里有个简单的办法. 我把\sdk\platform-tools目录中,文件名以"adb"开头的三个文件打包 ...

  9. 《第一行代码》学习笔记20-广播接收器Broadcast_Receiver(3)

    1.强制用户下线的逻辑并不是写在MainActivity里的,而是应该写在接收这条广播的广播接收器里面,这样强制下线的功能就不会 依附于任何的界面,不管是在程序的任何地方,只需要发出一条广播,就可以完 ...

  10. 基于webrtc的多人视频会话的demo运行程序

    服务端程序: 该服务程序为windows平台下的程序,使用libevent书写,并集成了UDP的中转程序.(该服务器程序不能和客户端程序运行在同一台PC机电脑,不然服务器程序和客户端程序会抢占同一UD ...