博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1552
阅读量:4982 次
发布时间:2019-06-12

本文共 1726 字,大约阅读时间需要 5 分钟。

                                      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 02 4 8 10 07 5 11 13 1 3 0-1

Sample Output

320

Source

Mid-Central USA 2003
#include 
#include
using namespace std;int main(){ int a[20]; cin>>a[0]; while(a[0]!=-1) { int n =1; int ans = 0; for(;;n++) { cin>>a[n]; if(a[n]==0) break; } for(int i=0;i
>a[0]; } return 0;}

 

转载于:https://www.cnblogs.com/jhldreams/p/3748082.html

你可能感兴趣的文章
windows下写的脚本,在linux下执行失败
查看>>
常用开源<监控软件>介绍
查看>>
C语言博客作业--函数嵌套调用
查看>>
How Many Tables
查看>>
还不研究Scatter?
查看>>
websoket在项目中的使用
查看>>
IDEA中Thrift插件配置
查看>>
sql.date
查看>>
CodeForces 559C Gerald and Gia (格路+容斥+DP)
查看>>
Ansible--安装,命令格式, ssh, command, shell, script, copy
查看>>
Linux 下wifi 驱动开发(三)—— SDIO接口WiFi驱动浅析(转)
查看>>
WP8.1开发:简单天气预报应用(转)
查看>>
iOS 审核加急通道使用--转载来源--有梦想的蜗牛
查看>>
百度地图-中国地图
查看>>
线性判别函数-Fisher 线性判别
查看>>
面试小题
查看>>
My latest news
查看>>
VisualStudio 2015 开启IIS Express可以调试X64项目
查看>>
Android程序的入口点是什么,不是Main()吗
查看>>
[bbk4992] 第98集 -第12章 -数据移植 04
查看>>