标签:
#include<iostream> #include<cstdio> #include<map> #include<algorithm> using namespace std ; #define M 500 + 10 int a[M] ; int b[M] ; int c[M] ; int d[M] ; int l ; int n ; int m ; map <int , bool > Map ; void Marge() { for(int i = 0 ;i < l ; ++ i) for(int j = 0 ;j < n ; ++ j) Map[a[i] + b[j]] = 1 ; } bool Check(int x) { int tem ; for(int i = 0 ;i <l ; ++ i) { tem = x - c[i] ; if(Map[tem]) return true ; } return false ; } int main() { int s ; int x ; int T = 1 ; while(scanf("%d%d%d",&l ,&n , &m) != EOF ) { for(int i = 0 ;i < l ; ++ i) scanf("%d",a + i) ; for(int i = 0 ;i < n ; ++ i) scanf("%d",b + i) ; for(int i = 0 ;i < m ; ++ i) scanf("%d",c + i) ; scanf("%d",&s) ; printf("Case %d:\n",T ++) ; Marge() ; while(s --) { scanf("%d",&x) ; if(Check(x)) puts("YES") ; else puts("NO") ; } Map.clear() ; } return 0 ; }
标签:
原文地址:http://www.cnblogs.com/program-ccc/p/4770455.html