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. [Hyperapp] Interact with the State Object through Hyperapp Action functions

    Hyperapp is an ultra lightweight (1kb), minimal, functional, JavaScript library for building UIs. It ...

  2. grep常见使用方法总结

    grep -E 'l\{2,\}' 2.txt grep -E 'h(ell|a)o' test.txt grep '[a-z]\{5,\}' test.txt grep -xf a.txt b.tx ...

  3. HH实习(hpu1287)(斐波那契运用)

    HH实习 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 44  Solved: 29 [Submit][id=1287">Status ...

  4. JUnit4.8.2源码分析-4 RunNotifier与RunListener

    JUnit4运行过程中,org.junit.runner.notification. RunListener和RunNotifier运用了观察者模式. 1.观察者 观察者Observer/Listen ...

  5. node12---mongodb

    一.传统数据库技术回顾 数据库就是存储数据的,那么存储数据就用txt就行了啊,为什么要有数据库? 理由之1: 数据库有行.列的概念,数据有关系,数据不是散的. 老牌数据库,比如MySQL.SQL Se ...

  6. m_Orchestrate learning system---十八、mo项目的启示是什么

    m_Orchestrate learning system---十八.mo项目的启示是什么 一.总结 一句话总结:多看教程,体统看教程的学, 完全不懂的话百度的作用也不大 多学点,可以节约后面的超多时 ...

  7. 91.Bower : ENOGIT git is not installed or not in the PATH 解决方法

    转自:https://www.haorooms.com/post/bower_error 今天在用bower安装依赖的时候,出现了Bower : ENOGIT git is not installed ...

  8. C++如何调用C#编写的 DLL

    由于C#编绎出来的DLL不是计算机所能直接识别的二进制指令码,需要CLS进行再解释,说到这,我想有些朋友应该知道C#项目需要引用C++编写的DLL时,可以直接引用DLLMPORT来实现调用,而反向的话 ...

  9. [ Linux ] user, password, sudoers

    - 1. Add Linux user,  setup password http://linux.vbird.org/linux_basic/0410accountmanager.php - 2. ...

  10. kinEditor动态渲染的问题

    摘自:jingyan.baidu.com/article/a65957f4a4c89a24e67f9b3d.html 在使用kindEditor时,因为textarea是动态加载的,因而对textar ...