HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
来源:互联网 发布:长寿 知乎 编辑:程序博客网 时间:2024/06/06 08:56
sequence1
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
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
Source
BestCoder Round #63 (div.2)
/************************************************************************/
附上该题对应的中文题
sequence1
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
问题描述
给定长度为n的序列a,求有多少对i,j(i<j),使得∣ai−aj∣ mod b=c
输入描述
若干组数据(大概5组)。每组数据第一行三个整数n(1≤n≤100),b,c(0≤c<b≤109)。接下来一行n个整数ai(0≤ai≤109)。
输出描述
对于每组数据,输出一行表示答案。
输入样例
3 3 21 2 33 3 11 2 3
输出样例
12
/****************************************************/
出题人的解题思路:
sequence1
按照题目要求,枚举任意两个数检查是否符合题意。
值得注意的是一开始所有数先对b取模这个方法是错误的。
其实此题的思路并没有多复杂,我们也不必想太多,题目怎么说,我们怎么暴力就行#pragma comment(linker, "/STACK:1024000000,1024000000")#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<cmath>#include<string>#include<algorithm>#include<iostream>#define exp 1e-4using namespace std;const int N = 105;const int M = 15005;const int inf = 1000000007;const int mod = 2009;int s[N];int main(){ int n,b,c,i,j,t; while(~scanf("%d%d%d",&n,&b,&c)) { t=0; for(i=0;i<n;i++) scanf("%d",&s[i]); for(j=0;j<n;j++) for(i=0;i<j;i++) if(abs(s[i]-s[j])%b==c) t++; printf("%d\n",t); } return 0;}菜鸟成长记
0 0
- HDU 5567 sequence1(暴力)——BestCoder Round #63(div.2)
- BestCoder Round #63 (div.2) HDOJ5567 sequence1(暴力)
- BestCoder Round #63 (div.2) sequence1
- HDU 5479 Scaena Felix(暴力)——BestCoder Round #57(div.2)
- HDU 5522 Numbers(暴力)——BestCoder Round #61(div.2)
- HDU 5595 GTW likes math(暴力,细节问题要注意)——BestCoder Round #66(div.2)
- HDU 5569 matrix(DP)——BestCoder Round #63(div.1 div.2)
- HDU 5670 Machine——BestCoder Round #81(div.2)
- HDU 4956 Poor Hanamichi(暴力)——BestCoder Round #5
- HDU 5366 The mook jong——BestCoder Round #50(div.1 div.2)
- HDU 5365 Run ——BestCoder Round #50(div.1 div.2)
- HDU 5428 The Factor——BestCoder Round #54(div.1 div.2)
- HDU 5429 Geometric Progression(大数模板)——BestCoder Round #54(div.1 div.2)
- HDU 5495 LCS(其实就是找环)——BestCoder Round #58(div.1 div.2)
- HDU 5587 Array(位运算)——BestCoder Round #64(div.1 div.2)
- HDU 5596 GTW likes gt(巧用multiset)——BestCoder Round #66(div.1 div.2)
- HDU 5671 Matrix——BestCoder Round #81(div.1 div.2)
- HDU 5672 String(尺取法)——BestCoder Round #81(div.1 div.2)
- Android 关闭和开启四大组件的方法
- Serializable中的serialVersionUID到底有啥用
- 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