POJ.1552 Doubles(水)

来源:互联网 发布:c语言99个例题 编辑:程序博客网 时间:2024/06/05 18:51

POJ.1552 Doubles(水)

题意分析

暴力

代码总览

#include <cstdio>#include <stdio.h>#define nmax 100using namespace std;int a[nmax];int n;int main(){    //freopen("in.txt","r",stdin);    while(true){        int t;        scanf("%d",&t);        if(t == -1) break;        if(t == 0){            printf("0\n");            continue;        }else{            int cnt = 0;            a[cnt++] =t;            while(scanf("%d",&t) && t!= 0){                a[cnt++] = t;            }            int ans = 0;            for(int i = 0; i<cnt;++i){                for(int j = 0; j<cnt;++j){                    if(i == j) continue;                    else{                        if(a[j] == 2* a[i]) ans++;                    }                }            }            printf("%d\n",ans);        }    }    return 0;}