比赛 20111108 评测结果 AAAAAAAAAT
题目名称 数对的个数 最终得分 90
用户昵称 fanzeyi 运行时间 0.000 s
代码语言 C 内存使用 0.00 MiB
提交时间 2011-11-08 10:40:26
显示代码纯文本
/*
ID: fanzeyi1
LANG: C
TASK: dec 
*/
/*
 * =====================================================================================
 *
 *       Filename:  dec.c
 *        Version:  1.0
 *        Created:  11/08/2011 09:00:58 AM
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  Zeray Fan, fanzeyi1994[at]gmail.com
 *        Company:  http://www.fanhe.org/
 *
 * =====================================================================================
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long num[200000]; 

int main(void) {
    FILE *fin = fopen("dec.in","r");
    FILE *fout = fopen("dec.out", "w");
    int i, j; 
    unsigned long count = 0; 
    unsigned long n, c;
    fscanf(fin, "%lu %lu\n", &n, &c); 
    for( i = 0 ; i < n ; i++ ) {
        fscanf(fin, "%ld", &num[i]); 
    }
    for( i = 0 ; i < n ; i++ ) {
        for( j = i + 1 ; j < n ; j++ ) {
            if(abs(num[i] - num[j]) == c) {
                count = count + 1; 
            }
        }
    }
    fprintf(fout, "%lu\n", count); 
    return 0;
}