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 ...
随机推荐
- How to avoid Over-fitting using Regularization?
http://www.mit.edu/~9.520/scribe-notes/cl7.pdf https://en.wikipedia.org/wiki/Bayesian_interpretation ...
- Mac标识物理位置算法 import Levenshtein mac列表特征值
mac 字符串 与 基准字符串的 Levenshtein 距离,考虑 mac信号强度的时序性,60秒内若干次变化 不引入强度 mac字符串的唯一性 如何排序 基准字符串的选取 同一尺度 都按强度 ...
- thinkphp5, 模板继承、模板布局
---------------------------------------------------------------------------------------------------- ...
- Django多对多的创建
1.多对多创建的应用场景: 在某表中创建一行数据是,有一个可以多选的下拉框 例如:创建用户信息,需要为用户指定多个爱好 2.创建方式: 方式一:自定义关系表,手动创建一张表用于关联其他多张表的关系 c ...
- Django——自定义分页(可调用)
1.view from django.shortcuts import render,HttpResponse # Create your views here. from app01.models ...
- Data Structure Array: Maximum of all subarrays of size k
http://www.geeksforgeeks.org/maximum-of-all-subarrays-of-size-k/ #include <iostream> #include ...
- 【leetcode刷题笔记】Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the arra ...
- P4455 [CQOI2018]社交网络(矩阵树定理)
题目 P4455 [CQOI2018]社交网络 \(CQOI\)的题都这么裸的吗?? 做法 有向图,指向叶子方向 \(D^{out}(G)-A(G)\) 至于证明嘛,反正也就四个定理,先挖个坑,省选后 ...
- HDU2612 -暑假集训-搜索进阶N
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82828#problem/N这两天总是因为一些小错误耽误时间,我希望自己可以细心点.珍惜 ...
- JAVA强制类型转换(转载+自己的感想) - stemon
JAVA强制类型转换(转载+自己的感想) - stemon 时间 2013-10-29 15:52:00 博客园-Java原文 http://www.cnblogs.com/stemon/p/33 ...