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. PHP浮点数引起的四舍五入问题

    同事在开发中,遇到一个浮点数问题,过来问我,问题如下: $a = 0.705; $b = 20.795; $c = 20.715; $d = 20.745; echo sprintf('%0.2f', ...

  2. django最简单表单入门

    两个html页面,存放于某个应用下的templates文件夹下. index.html 提交 点击“提交”按钮后,会调入第二个页面hello.html显示文本框的内容 原理是通过form的action ...

  3. Roads in the North(POJ 2631 DFS)

    Description Building and maintaining roads among communities in the far North is an expensive busine ...

  4. 线程池之ThreadPool类与辅助线程 - <第二篇>

    一.CLR线程池 管理线程开销最好的方式: 尽量少的创建线程并且能将线程反复利用(线程池初始化时没有线程,有程序请求线程则创建线程): 最好不要销毁而是挂起线程达到避免性能损失(线程池创建的线程完成任 ...

  5. Match类

    Regex在匹配的时候,常常会返回一个Match类的对象,今天就来看看怎么玩这个对象. 一.属性 Captures 按从里到外.从左到右的顺序获取由捕获组匹配的所有捕获的集合(如果正则表达式用 Reg ...

  6. Qt编程之QtScript

    需求是这样的: 需要给一个硬件接口测试些东西,用js来调用,js做成不同的独立模块分别测试不同的硬件接口,包括DMD内存,PCIE带宽等等.需要用一个exe来载入这些js文件分别调用测试模块.exe用 ...

  7. Calendar中add函数和roll函数的用法及区别

    Calendar中add()和roll()函数的用法一.取某个时间点后的整点时刻.例如1984年7月7日15:23:05后的整点时刻即为1984-07-07 16:00:00.实现如下:Calenda ...

  8. UESTC_方老师分身 I CDOJ 914

    方老师分身 I Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit S ...

  9. canvas动画文字效果

    Doughnut Chartvar c=document.getElementById("canvas");var ctx=c.getContext("2d") ...

  10. oracle数据库时间转换

    select * from TAB where 时间 BETWEEN to_date('2011-02-01 22:03:40','yyyy-mm-dd hh24:mi:ss') and to_dat ...