fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <numeric>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. const int X = 6;
  10.  
  11. int main() {
  12. std::vector<int> v = {
  13. 0, 1, 2, 3, 4, 5,
  14. 6, 7, 8, 9, 10, 11,
  15. 12, 13, 14, 15, 16, 17,
  16. 18, 19, 20, 21, 22, 23,
  17. 24, 25, 26, 27, 28, 29,
  18. 30, 31, 32, 33, 34, 35
  19. };
  20.  
  21. int sum = std::accumulate(v.begin(), std::partition(v.begin(), v.end(), [] (int i) {
  22. return ((((i % X) > (i % (X+1))) && ((i % (X+1))!=0)) || (i>0 && i<X));
  23. }), 0);
  24. cout << sum;
  25. }
Success #stdin #stdout 0s 4312KB
stdin
Standard input is empty
stdout
175