标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 42 Accepted Submission(s): 38
题解:水,刚开始还以为要判断数据重复的情况呐,最后发现根本不用,是 how many pairs (i,j) ,指的是i,j的对数。。。
题意就是找 how many pairs (i,j) ( i < j ) for abs(ai−aj) mod b=c.
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #define mem(x,y) memset(x,y,sizeof(x)) using namespace std; const int INF=0x3f3f3f3f; const double PI=acos(-1.0); typedef long long LL; LL m[110]; bool judge(int a,int c,int b){ if((a-c)%b==0)return true; else return false; } int main(){ int n,b,c; while(~scanf("%d%d%d",&n,&b,&c)){ for(int i=0;i<n;i++)scanf("%I64d",m+i); LL ans=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(judge(abs(m[i]-m[j]),c,b))ans++; } } printf("%I64d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4984878.html