fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. vector<int> res;
  7. cin>>n;
  8. if (n%2 == 1)
  9. {
  10. n -= 3;
  11. res.push_back(3);
  12. }
  13. while (n > 0)
  14. {
  15. res.push_back(2);
  16. n -= 2;
  17. }
  18. cout<<res.size()<<endl;
  19. for (int i=0; i<res.size(); i++)
  20. cout<<res[i]<<" ";
  21. return 0;
  22. }
Success #stdin #stdout 0s 4544KB
stdin
6
stdout
3
2 2 2