Hdu5567/bestcoder Round #63 (Div.2) A Sequence1 Water

Source: Internet
Author: User

Sequence1
Given an arrayaWith lengthN, could you tell me how many pairs(i,J) (I < J) fora Bs (ai−a j)  mod b=c .

InputSeveral Test Cases (about5)

For each cases, first come 3 integers,N,b,C(1≤n≤,0≤c<b≤9 )

Then followsNIntegersAi(0≤ai≤9)

OutputFor each cases, please output an integer in a line as the answer.

Sample Input3 3 21 2 33 3 11 2 3

Sample Output12   The following:

According to the requirements of the topic, enumerate any two numbers to check if the test instructions is compliant.

It is important to note that the first method of modeling b b is wrong.

///1085422276#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<vector>#include<queue>#include<map>#include<stack>using namespaceStd;typedefLong Longll;#defineMem (a) memset (A,0,sizeof (a))#definePB Push_backinline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){        if(ch=='-') f=-1; ch=GetChar (); }     while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar (); }returnx*F;}//****************************************Const intn=100000+ -;#defineMAXN 100000+5intMain () {intN,b,c,a[n];  while(SCANF ("%d%d%d", &n,&b,&c)! =EOF) {         for(intI=1; i<=n;i++) {scanf ("%d",&A[i]); }intans=0;  for(intI=1; i<=n;i++) {             for(intj=i+1; j<=n;j++) {                if(ABS (A[i]-a[j])%b==c) {ans++; }}}cout<<ans<<Endl; }    return 0;}
Code

Hdu5567/bestcoder Round #63 (Div.2) A Sequence1 Water

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.