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. kafka-manager安装

    代码地址: https://github.com/yahoo/kafka-manager 注意只能使用 Java 7!Java 6 编译不通过,Java 8 在运行的时候会报错:java.lang.U ...

  2. mac Word 怎样放大缩小文档结构图文字大小

    在文档结构图的侧栏里按住control+option,然后滑动鼠标滚轮/双指上下滚动触摸板.

  3. [XMPP]简易的聊天室实现[二](使用CocoaAsyncSocket)

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  4. log4cplus配置文件使用

    简介 log4cplus是log4j的c++移植版,是c++中一个很好的打印日志的库.它与另外一个c++的log库log4cxx相比较,好处是不依赖于libapr和libaprutil,可以静态链接到 ...

  5. Eclipse插件Mylyn管理上下文任务管理

    原文地址:http://www.ibm.com/developerworks/cn/java/j-mylyn1/ Mylyn 2.0,第 1 部分: 集成的任务管理 使用集成的 Eclipse 问题跟 ...

  6. tomcat配置访问日志,访问首页主目录

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" ...

  7. HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET

    HTML5 Canvas动画效果演示 - 流浪的鱼 - 博客频道 - CSDN.NET HTML5 Canvas动画效果演示

  8. ubuntu下的Samba配置:使每个用户可以用自己的用户名和密码登录自己的home目录

    http://blog.csdn.net/fly_qj/article/details/21744797 1.先要安装Samba sudo apt-get install samba openssh- ...

  9. 机器学习 1、R语言

    R语言 R是用于统计分析.绘图的语言和操作环境.R是属于GNU系统的一个自由.免费.源代码开放的软件,它是一个用于统计计算和统计制图的优秀工具. 特点介绍 •主要用于统计分析.绘图.数据挖掘 •R内置 ...

  10. 使用Comparable接口的小例子

    代码: public class Student implements Comparable<Student> { private int id; private String name; ...