Problem Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formula Ai+Bj+Ck = X. |
Input There are many cases. Every data case is described as followed: In the first line there are three integers L, N, M, in the second line there are L integers represent the sequence A, in the third line there are N integers represent the sequences B, in the forth line there are M integers represent the sequence C. In the fifth line there is an integer S represents there are S integers X to be calculated. 1<=L, N, M<=500, 1<=S<=1000. all the integers are 32-integers. |
Output For each case, firstly you have to print the case number as the form "Case d:", then for the S queries, you calculate if the formula can be satisfied or not. If satisfied, you print "YES", otherwise print "NO". |
Sample Input 3 3 31 2 31 2 31 2 331410 |
Sample Output Case 1:NOYESNO |
Code 1 #include
|
Key Points Firstly of all, I should be careful. I take a whole afternoon to find the fault which is missing the ":". Secondly, I should proficient in the binsearch algorithm, whose range is [], and the condition is ≥, and u must add -1 or +1. Thirdly, in C, u can only use qsort. and if u want use the function, u must add the head file "#include <stdlib.h>", and the "compare" function. Fourthly, if u want use function, such strcpy, u should add "#include <string.h>", which is belong to C. And if u want use the type of "string", u should add "#include <string> using namespace std;". Those head files are really different. Last but not the least, if u want debug, u can remember those short key, likes Ctrl+F10, which means u can run until the cursor, Shift+F5, which means stop. |
Recommend 威士忌 |