Doubles

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3927    Accepted Submission(s):
2732

Problem 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 file 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 <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
int a[];
//freopen("in.txt","r",stdin);
while(cin>>n&&n!=-)
{
int count=,i=,j=,sum=;
a[]=n;
while(cin>>a[count++]&&a[count-]!=);
count-=;
for(i=;i<count;i++)
{
for(j=;j<count;j++)
{
if(a[i]==*a[j])
sum++;
}
}
cout<<sum<<endl;
}
}
 

Doubles water!!!!!!只会水题怎么破的更多相关文章

  1. HDU 5443 The Water Problem (水题,暴力)

    题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #includ ...

  2. HDU 5832 A water problem (水题,大数)

    题意:给定一个大数,问你取模73 和 137是不是都是0. 析:没什么可说的,先用char 存储下来,再一位一位的算就好了. 代码如下: #pragma comment(linker, "/ ...

  3. Atcoder 水题选做

    为什么是水题选做呢?因为我只会水题啊 ( 为什么是$Atcoder$呢?因为暑假学长来讲课的时候讲了三件事:不要用洛谷,不要用dev-c++,不要用单步调试.$bzoj$太难了,$Topcoder$整 ...

  4. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  5. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  6. HDU 5832 A water problem (带坑水题)

    A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

  7. SRM 584 第一次玩TopCoder。。。只水题一道。。。

    第一次topcoder,以前老感觉没有资格去做tc,cf什么的,现在已经慢慢接触了. 感觉还可以,还是有让我们这些蒻菜安慰的水题. tc的确很好玩,用客户端比赛,还有各种规则,而且还是只编写一个类提交 ...

  8. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  9. Poj 1552 Doubles(水题)

    一.Description As part of an arithmetic competency program, your students will be given randomly gene ...

随机推荐

  1. node.js 环境搭建

    一 官网下载安装包 : 1.http://www.nodejs.org/download/ 选择相应的包进行安装 2.安装express : npm install -g express -gener ...

  2. ThreadLocal的使用 .

    早在Java 1.2推出之时,Java平台中就引入了一个新的支持:java.lang.ThreadLocal,给我们在编写多线程程序时提供了一种新的选择.使用这个工具类可以很简洁地编写出优美的多线程程 ...

  3. 关于bootstrap列偏移的两种方式

    第一种方式: <div class="col-md-2 col-md-offset-9"> <input type="text" class= ...

  4. 在virtualenv中安装libxml2和libxslt

    在使用python的工作中,需要使用到libxml2和libxslt库.原来在实际环境中已经安装完成了,但是在virtualenv中还没有,现在正在整理virtualenv的环境.下面把在virtua ...

  5. Measuring Lengths in Baden

    Description Measuring Lengths in Baden time limit per test: 2 seconds memory limit per test: 256 meg ...

  6. information_schema.column_privileges 学习

    mysql 的授权是分层次的 实例级 | 库级 | 表级 | 列级 而这些授权信息被保存在了mysql.user | mysql.db | mysql.tables_priv | mysql.colu ...

  7. Resharper使用

    Resharper进阶一:简要介绍 官方下载地址下载地址  注册码: 用户名: User 注册码:D9d09DSYJel9IyuDU4btAQwZcbLugUad 面对这样一个问题:为什么.net能够 ...

  8. checkbox选中问题

    <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312&qu ...

  9. curl fake ip

    curl --header "X-Forwarded-For: 219.137.148.2" "http://www.x.com"

  10. WPF/ArcGIS Engine三维开发和EVC3/4升级到VS项目建议(转)

    系统环境:Windows 7 专业版,Visual Studio 2010,ArcGIS Engine 9.3 1.创建项目 创建一个WPF的项目,必须选择.Net framework 3.5(AE9 ...