数据非常小,直接枚举即可!
#include<cstdio> int a[30]; int main(){ int n=1; scanf("%d",&a[n]); while (a[n]!=0){ n++; scanf("%d",&a[n]); } n=n-1; int sum=0; for (int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) if (a[i]==2*a[j]||a[j]==2*a[i])sum++; printf("%d ",sum); return 0; }