Back to the Training Home
Back to the Training Home
Lesson: 30
Problem: 1930
Title: Doubles
Difficulty Level: 1.0
Date: FEB 28, 2009
Site: http://acm.tju.edu.cn/toj/
I think i do not need to write any analysis for this problem. This problem is very suitable for very beginners.
Solution:
Source Code:
#include<stdio.h> #define maxn 20
int A[maxn]; char Flag[300]; void FindAnswer(int n) { int i, res = 0; for(i = 0; i<n; i++) { if(Flag[A[i]*2]) res++; } printf("%d\n",res); for(i = 0; i<n; i++) Flag[A[i]] = 0; }
int main() { int n; while(1) { scanf("%d",&A[0]); if(A[0] == -1) break; Flag[A[0]] = 1; n = 1; while(1) { scanf("%d",&A[n]); if(!A[n]) break; Flag[A[n]] = 1; n++; } FindAnswer(n); } return 0; }