sequence1

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 345    Accepted Submission(s): 254

Problem Description
Given an array a
with length n,
could you tell me how many pairs (i,j)
( i < j ) for abs(ai−aj) mod b=c.
 
Input
Several test cases(about
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)
 
Output
For each cases, please output an integer in a line as the answer.
 
Sample Input
3 3 2
1 2 3
3 3 1
1 2 3
 
Sample Output
1
2
 
Source
 
Recommend
hujie   |   We have carefully selected several similar problems for you:  5589 5588 5587 5586 5585

#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(水题)的更多相关文章

  1. HDOJ 1070 Milk(水题,考英文的)

    Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choo ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. 水题 HDOJ 4727 The Number Off of FFF

    题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...

  4. 水题 HDOJ 4716 A Computer Graphics Problem

    题目传送门 /* 水题:看见x是十的倍数就简单了 */ #include <cstdio> #include <iostream> #include <algorithm ...

  5. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  6. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

  7. HDOJ/HDU 2560 Buildings(嗯~水题)

    Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...

  8. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

  9. HDOJ(HDU) 1859 最小长方形(水题、、)

    Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...

  10. HDOJ(HDU) 1555 How many days?(水题)

    Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...

随机推荐

  1. How to get the MouseEvent coordinates for an element that has CSS3 Transform?

    I want to detect where a MouseEvent has occurred, in coordinates relative to the clicked element. Wh ...

  2. Python——异常基础

    异常基础 在Python中,异常会依据错误自己主动地被触发.也能由代码触发和截获.异常由五个语句处理: 1.[try/except]:捕捉由Python或你引起的异常并恢复. 2.[try/final ...

  3. postMan模拟get和post请求,支持局域网和外网

    chrome应用postMan,可以安装一下,非常方便. 可以FQ下载安装. post参数要在body中设置 get参数直接在url中

  4. Android UnitTest FrameWork

    Android test suites基于Junit,可以直接使用Junit测试不使用android api的class,也可以使用android的Junit extensions测试android ...

  5. Devexpress控件使用一:GridControl

    1.控件及列表展示 1).控件 2).构建表格,用于列表展示 3).gridControl绑定数据 4).调用绑定:BindDataSource(InitDt()); 5).展示列表 2.表格的列配置 ...

  6. 改变GridView中列的宽度

    <asp:TemplateField HeaderText="规格型号" HeaderStyle-Width="24%">

  7. 【原创】java中各种集合类的实现浅析

    [LinkedList] LinkedList使用了链表来实现List功能,而且是双向循环链表,它的Entry定义如下: private static class Entry<E> { / ...

  8. 【原创】Apache和基于虚拟主机的Tomcat集群方案

    最近建设了北京某政府机构的网站,网站前段使用Apache做负载均衡,后端使用Tomcat做的集群,基于虚拟主机的方式访问,并且实现了静态资源和动态资源的分离. 开始的建设方案有两种,一种是使用apac ...

  9. javascript 异或运算符实现简单的密码加密功能

    写在前面的 当我们需要在数据库中存储用户的密码时,当然是不能明文存储的. 我们就是介绍一下用^运算符来实现简单的密码加密以及解密功能 上代码 首先,回顾一下基础知识. String.fromCharc ...

  10. split方法切割数组

    指定的字符串按"o"截取 当一个base64需要剪去前面的部分的时候 var params={ "imgJustBase64":this.zheng.split ...