Advertisement
newb_ie

Untitled

Oct 4th, 2021
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. //https://codeforces.com/problemset/problem/535/B
  4. //https://atcoder.jp/contests/abc221/tasks/abc221_c
  5. //https://atcoder.jp/contests/abc198/tasks/abc198_d
  6. //https://codeforces.com/contest/1553/problem/C
  7.  
  8.  
  9. vector<string> res;
  10. int n = 10;
  11.  
  12. void rec (int i,string s) {
  13. if (i == n) {
  14. res.push_back(s);
  15. return;
  16. }
  17. rec(i + 1,s + '0');
  18. rec(i + 1,s + '1');
  19. }
  20.  
  21. int main () {
  22. ios::sync_with_stdio(false);
  23. cin.tie(nullptr);
  24. cout.tie(nullptr);
  25. rec(0,"");
  26. vector<int> a = {2,10,3,3,7,3,2,1,22,33};
  27. //~ 1100000110
  28. //~ 2 + 10 + 1 + 22 = 35
  29. int sum = 35;
  30. for (string s : res) {
  31. int sum2 = 0;
  32. for (int i = 0; i < (int) s.size(); ++i) {
  33. if (s[i] == '1') {
  34. sum2 += a[i];
  35. }
  36. }
  37. if (sum2 == sum) {
  38. cout << s << '\n';
  39. }
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement