Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector<int>v;
- int main()
- {
- int t,i,j,cnt=0,k,sz,a;
- cin>>t;
- for(i=1;i<=t;i++)
- {
- v.clear();
- for(j=1;j<=9;j++)
- {
- cin>>a;
- if(a>10)cnt++;
- for(k=0;k<a;k++)
- v.push_back(j);
- }
- sort(v.begin(),v.end());
- cout<<"Case #"<<i<<": ";
- if(cnt>=3)
- {
- cout<<"YES\n";
- continue;
- }
- sz=v.size();
- int sum;
- do
- {
- sum=0;
- for(k=0;k<sz;k++)
- {
- if(k%2)sum+=v[k];
- else sum-=v[k];
- }
- if(sum%11==0)
- break;
- }while(next_permutation(v.begin(),v.end()));
- if(sum%11==0)
- cout<<"YES\n";
- else cout<<"NO\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement