hdoj sequence1 5567 (简单暴力)
2015-11-21 21:59
471 查看
sequence1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 48 Accepted Submission(s): 42
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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)
[align=left]Output[/align]
For each cases, please output an integer in a line as the answer.
[align=left]Sample Input[/align]
3 3 2
1 2 3
3 3 1
1 2 3
[align=left]Sample Output[/align]
1
2
#include<stdio.h> #include<stdio.h> #include<algorithm> using namespace std; int a[110]; int p[10010]; int main() { int n,b,c; int i,j; while(scanf("%d%d%d",&n,&b,&c)!=EOF) { for(i=1;i<=n;i++) scanf("%d",&a[i]); int k=0; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { p[k++]=abs(a[i]-a[j]); } } int m=0; for(i=0;i<k;i++) { if(p[i]%b==c) m++; } printf("%d\n",m); } return 0; }
相关文章推荐
- HDOJ 5567 sequence1
- HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
- IOS_改变UITextField placeHolder颜色、字体
- Serializable中的serialVersionUID到底有啥用
- BestCoder Round #63 (div.2) sequence1
- INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)的解决
- UI基础-UITableView表视图
- 旋转编码器的Arduino使用方法
- poj2299Ultra-QuickSort【逆序数】
- hdu 5567 sequence1(水)
- 判断用户输入是否是数字
- Checklists学习日志之UITableView的全部属性、方法以及代理方法执行顺序
- UILable的lineBreakMode
- 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
- HDOJ--3836--Equivalent Sets(tarjan算法)//求连接几个SCC最少的边
- easyui 使用 mark
- 对话框视图UIAlertView,上拉菜单UIActionSheet,以及9.0之后完全取代他们的的UIAlertController
- UI - Xcode 7 使用xib设置控件圆角
- 1007. Maximum Subsequence Sum (25)
- UISlider