HDOJ 5567 sequence1
来源:互联网 发布:无锡产业结构数据2015 编辑:程序博客网 时间:2024/06/05 10:16
sequence1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 31 Accepted Submission(s): 29
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 followsn integers ai(0≤ai≤109)
For each cases, first come 3 integers,
Then follows
Output
For each cases, please output an integer in a line as the answer.
Sample Input
3 3 21 2 33 3 11 2 3
Sample Output
12
题意:给定长度为n的序列的序列a,求有多少对i,j(i<j),使得|ai-aj| mod b ==c。
水题,今天也就过了这一题,膝盖碎了。QAQ~~~
代码如下:
#include<cstdio>#include<cstring>#include<cstdlib>int a[110];int main(){int n,i,j,b,c,ans;while(scanf("%d%d%d",&n,&b,&c)!=EOF){for(i=0;i<n;++i)scanf("%d",&a[i]);ans=0;for(i=0;i<n;++i){for(j=i+1;j<n;++j){if(abs(a[i]-a[j])%b==c)ans++;}}printf("%d\n",ans);}return 0;}
0 0
- hdoj 5567 sequence1 【水题】
- HDOJ 5567 sequence1
- HDOJ 5567 sequence1 (暴力)
- hdoj--5567--sequence1(水题)
- hdoj sequence1 5567 (简单暴力)
- hdu 5567 sequence1(水)
- HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
- BestCoder Round #63 (div.2) sequence1
- BestCoder Round #63 (div.2) HDOJ5567 sequence1(暴力)
- HDOJ
- hdoj
- hdoj
- HDOJ
- hdoj 1568 && hdoj 5344 && hdoj 5444
- HDOJ 2176
- Hdoj--1272
- hdoj 1003
- hdoj 1005
- Java中类加载过程和对象创建过程
- recvmsg 断包问题
- angular的基础知识
- HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
- Linxu笔记(7): 用户信息管理
- HDOJ 5567 sequence1
- 获取QQ好友共同好友列表信息
- BC63 matrix
- Linxu笔记(8): su root误区
- 百度前端学院春季任务三笔记
- Linxu笔记(9): ACL权限
- kvm qemu pci passthough
- 18 款超酷的 HTML5 和 JavaScript 游戏引擎库
- 关于limit_req和limit_conn的区别