Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int main(){
- int t; cin >> t;
- while(t--){
- int n; cin >> n;
- int a[n], i;
- for(i = 0; i < n; i++){
- cin >> a[i];
- }
- sort(a, a+n);
- int x, flag = 0, j, k, l; cin >> x;
- for(i = 0; i < n-3; i++){
- for(j = i+1; j < n-2; j++){
- for(k = j+1; k < n-1; k++){
- for(l = k+1; l < n; l++){
- if(a[i] + a[j] + a[k] + a[l] == x){
- flag = 1;
- break;
- }
- }
- if(flag) break;
- }
- if(flag) break;
- }
- if(flag) break;
- }
- if(flag) cout << "1\n";
- else cout << "0\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment