zoukankan      html  css  js  c++  java
  • hdu 5567 sequence1(水)

     
    问题描述
    给定长度为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≤10^9)
    输出描述
    对于每组数据,输出一行表示答案。
    输入样例
    3 3 2
    1 2 3
    3 3 1
    1 2 3
    输出样例
    1
    2
     1 #pragma comment(linker, "/STACK:1024000000,1024000000")
     2 #include<iostream>
     3 #include<cstdio>
     4 #include<cstring>
     5 #include<cmath>
     6 #include<math.h>
     7 #include<algorithm>
     8 #include<queue>
     9 #include<set>
    10 #include<bitset>
    11 #include<map>
    12 #include<vector>
    13 #include<stdlib.h>
    14 #include <stack>
    15 using namespace std;
    16 #define PI acos(-1.0)
    17 #define max(a,b) (a) > (b) ? (a) : (b)
    18 #define min(a,b) (a) < (b) ? (a) : (b)
    19 #define ll long long
    20 #define eps 1e-10
    21 #define MOD 1000000007
    22 #define N 106
    23 #define inf 1e12
    24 int n,b,c;
    25 int a[N];
    26 int main()
    27 {
    28    while(scanf("%d%d%d",&n,&b,&c)==3){
    29       for(int i=0;i<n;i++){
    30          scanf("%d",&a[i]);
    31       }
    32       int ans=0;
    33       for(int i=0;i<n;i++){
    34          for(int j=i+1;j<n;j++){
    35             if(abs(a[i]-a[j])%b==c){
    36                ans++;
    37             }
    38          }
    39       }
    40       printf("%d
    ",ans);
    41    }
    42     return 0;
    43 }
    View Code
     
  • 相关阅读:
    kuangbin_ShortPath K (POJ 3159)
    kuangbin_ShortPath I (POJ 2240)
    kuangbin_ShortPath H (POJ 3660)
    kuangbin_ShortPath G (POJ 1502)
    kuangbin_ShortPath J (POJ 1511)
    kuangbin_ShortPath F (POJ 3259)
    kuangbin_ShortPath E (POJ 1860)
    StoryBoard中使用xib
    iOS APP 架构漫谈[转]
    Mac 快速修改 hosts 文件
  • 原文地址:https://www.cnblogs.com/UniqueColor/p/4984775.html
Copyright © 2011-2022 走看看