Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- set<int>store;
- vector<int>score;
- void make()
- {
- int i;
- store.insert(0);
- for(i=1; i<=20; i++)
- {
- store.insert(i);
- store.insert(i*2);
- store.insert(i*3);
- }
- store.insert(50);
- for(auto it : store)
- {
- score.push_back(it);
- }
- }
- int main()
- {
- make();
- int total,i,j,k,sum,per,len;
- while(scanf("%d",&total)==1)
- {
- if(total<=0)
- {
- printf("END OF OUTPUT\n");
- break;
- }
- per = 0;
- set<set<int>>com;
- len = score.size();
- for(i=0; i<len && score[i]<=total; i++)
- {
- for(j=0; j<len && score[j]<=total-score[i]; j++)
- {
- for(k=0; k<len && score[k]<=total-score[i]-score[j]; k++)
- {
- sum = score[i]+score[j]+score[k];
- if(sum==total)
- {
- set<int>combination;
- combination.insert(score[i]);
- combination.insert(score[j]);
- combination.insert(score[k]);
- com.insert(combination);
- per++;
- }
- }
- }
- }
- if(per>0)
- {
- printf("NUMBER OF COMBINATIONS THAT SCORES %d IS %d.\n",total,com.size());
- printf("NUMBER OF PERMUTATIONS THAT SCORES %d IS %d.\n",total,per);
- }
- else
- {
- printf("THE SCORE OF %d CANNOT BE MADE WITH THREE DARTS.\n",total);
- }
- printf("**********************************************************************\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment