Poj 1552 Doubles(水题)
一、Description
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 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
二、题解
水题啊,今天把水题都做完了,以后我要怎么办啊!!
三、Java代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int i,j,k,sum;
int a[]=new int[16];
while((a[0]=sc.nextInt())!=-1){
i=1;
sum=0;
while((a[i]=sc.nextInt())!=0){
i++;
}
for(k=0;k<i;k++){
for(j=0;j<i;j++){
if(a[k]*2==a[j])
sum++;
}
}
System.out.println(sum);
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Poj 1552 Doubles(水题)的更多相关文章
- POJ.1552 Doubles(水)
POJ.1552 Doubles(水) 题意分析 暴力 代码总览 #include <cstdio> #include <stdio.h> #define nmax 100 u ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- poj 3264 RMQ 水题
题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...
- POJ 1552 Doubles (C++ STL set使用)
题目: 题意:题意:给出几个正数(2~15个),然后就是求有这些数字的2倍有没有和原先的正数相同的,求出有几个,没有就是0. 分析:水题.用数组解决,开一个数组存正数,另开一个数组用来存这些数的2倍, ...
- 最小费用最大流模板 poj 2159 模板水题
Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15944 Accepted: 8167 Descr ...
- POJ 1837 Balance 水题, DP 难度:0
题目 http://poj.org/problem?id=1837 题意 单组数据,有一根杠杆,有R个钩子,其位置hi为整数且属于[-15,15],有C个重物,其质量wi为整数且属于[1,25],重物 ...
- POJ - 3090 gcd水题
大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判) 正解应该是欧拉函数或者高逼格的莫比乌斯反演 但数据实在太水直接打表算了 /*H E A ...
- POJ 1654 Area(水题)
题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...
- poj 1552 Doubles
#include <stdio.h> #include <stdlib.h> ]; int cmp(const void *a, const void *b) { return ...
随机推荐
- POJ 1845-Sumdiv【经典数学题目---求因子和】
转载请注明出处:http://blog.csdn.net/lyy289065406/article/details/6648539 優YoU http://user.qzone.qq.com/289 ...
- swift 一句代码补全tableView分割线
1.swift实现分割线补全 swift一个大进步,只要设置tableView.separatorInset = UIEdgeInsets.zero即可补全分割线, 2.OC实现分割线补全 而在OC中 ...
- Future Promise 模式(netty源码9)
netty源码死磕9 Future Promise 模式详解 1. Future/Promise 模式 1.1. ChannelFuture的由来 由于Netty中的Handler 处理都是异步IO ...
- value too great for base (error token is "08")
shell 中,经常有定时任务, 这时候shell脚本中一般会对时间进行一些判断,或者相关逻辑的操作 这时候,如果你获取的小时或者分钟是08,09,如果要再对其进行运算符或者比较的话,就会报标题的错误 ...
- windows中检查端口占用
在cmd中怎么输入netstat -aon|findstr "9080" 返回: UDP 0.0.0.0:8001 *.* 其中的4220为进城PID
- CSS选择器(三)
九.CSS 伪类 (Pseudo-classes) CSS 伪类用于向某些选择器添加特殊的效果. CSS 伪类 (Pseudo-classes)实例: 1.向文档中的超链接添加不同的颜色. <s ...
- 用Java实现断点续传的基本思路和代码
用Java实现断点续传的基本思路和代码 URL url = new URL(http://www.oschina.net/no-exist.zip); HttpURLConnection http ...
- shiro1
基于角色的访问控制 RBAC(role based access control),基于角色的访问控制. 比如: 系统角色包括 :部门经理.总经理.(角色针对用户来划分) 系统代码中实现: //如果该 ...
- Vue-Quill-Editor回显不显示空格的处理办法
我自己在用VUE做一个博客网站,查了一下好多人都在用Vue-Quill-Editor,于是我也把这个插件加入到我的程序里,可是后来却出现了个问题,如图: 简单的代码如下: <template&g ...
- python操作mysql(一)原生模块pymysql
一.下载安装 pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同. 下载安装 C:\Users\Administrator>pip install pymysq ...