// sum for k=1..n of {k*(k+1) if it does not divide by 4} #include #include #include #include #include using namespace std; int main () { int n; cin >> n; // 7 vector v (n); iota (v.begin (), v.end (), 1); // 1 2 3 4 5 6 7 transform (v.begin (), v.end (), v.begin (), [&] (int x) {return x * (x + 1);}); // 2 6 12 20 30 42 56 auto new_end = remove_if (v.begin (), v.end (), [&] (int x) {return x % 4 == 0;}); // 2 6 30 42|30 42 56 auto s = accumulate (v.begin (), new_end, 0LL); cout << s << endl; // 80 return 0; }