hdoj--5567--sequence1(水题)
sequence1
Total Submission(s): 345 Accepted Submission(s): 254
with length n,
could you tell me how many pairs (i,j)
( i < j ) for abs(ai−aj) mod b=c.
5)
For each cases, first come 3 integers, n,b,c(1≤n≤100,0≤c<b≤109)
Then follows n
integers ai(0≤ai≤109)
3 3 2
1 2 3
3 3 1
1 2 3
1
2
#include<stdio.h>
#include<string.h>
#include<math.h>
int n,b,c;
long long a[1010];
bool judge(long long x,long long y)
{
if(abs(x-y)%b==c)
return true;
return false;
}
int main()
{
while(scanf("%d%d%d",&n,&b,&c)!=EOF)
{
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)
scanf("%lld",&a[i]);
int sum=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(judge(a[i],a[j]))
sum++;
}
}
printf("%d\n",sum);
}
return 0;
}
hdoj--5567--sequence1(水题)的更多相关文章
- HDOJ 1070 Milk(水题,考英文的)
Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choo ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- 水题 HDOJ 4727 The Number Off of FFF
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...
- 水题 HDOJ 4716 A Computer Graphics Problem
题目传送门 /* 水题:看见x是十的倍数就简单了 */ #include <cstdio> #include <iostream> #include <algorithm ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
- HDOJ/HDU 1256 画8(绞下思维~水题)
Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...
- HDOJ/HDU 2560 Buildings(嗯~水题)
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...
- HDOJ(HDU) 2090 算菜价(简单水题、)
Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...
- HDOJ(HDU) 1859 最小长方形(水题、、)
Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...
- HDOJ(HDU) 1555 How many days?(水题)
Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...
随机推荐
- 51 nod 1431 快乐排队
1431 快乐排队 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注 有一群人在排队,如果某个人想排到前面去,可以花 ...
- Linux 网络搭建
如果系统环境崩溃. 调用/usr/bin/vim /etc/profile Windows 1 本地连接使用固定IP vmware 8 2 修改Windows的hosts地址 ...
- tddl
淘宝根据自己的业务特点开发了TDDL(Taobao Distributed Data Layer 外号:头都大了 ?_Ob)框架,主要解决了分库分表对应用的透明化以及异构数据库之间的数据复制,它是一个 ...
- STL_算法_对全部元素排序(sort、stable_sort)
C++ Primer 学习中. . . 简单记录下我的学习过程 (代码为主) //大部分容器适用.不适用于list容器 sort(b,e) sort(b,e,p) stable_sort(b,e) ...
- [Gatsby] Install Gatsby and Scaffold a Blog
In this lesson, you’ll install Gatsby and the plugins that give the default starter the ability to t ...
- HDU 5410(2015多校10)-CRB and His Birthday(全然背包)
题目地址:HDU 5410 题意:有M元钱,N种礼物,若第i种礼物买x件的话.会有Ai*x+Bi颗糖果,现给出每种礼物的单位价格.Ai值与Bi值.问最多能拿到多少颗糖果. 思路:全然背包问题. dp[ ...
- openssl之EVP系列之10---EVP_Sign系列函数介绍
openssl之EVP系列之10---EVP_Sign系列函数介绍 ---依据openssl doc/crypto/EVP_SignInit.pod翻译 (作者:DragonKing, ...
- python学习之--安装IDE(eclipse+pydev)
First steps download eclipse url:http://www.eclipse.org/downloads/ select Help -> Install New Sof ...
- Ubuntu 16.04 安装 Open Jdk
sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-7-jdk
- ES不设置副本是非常脆弱的,整个文章告诉了你为什么
Delaying Shard Allocation As discussed way back in Scale Horizontally, Elasticsearch will automatica ...