fork(1) download
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <vector>
  4. #include <set>
  5. #include <map>
  6. #include <queue>
  7. #include <stack>
  8. #include <string>
  9. #include <sstream>
  10. #include <memory.h>
  11. #include <time.h>
  12. #include <stdlib.h>
  13. #include <algorithm>
  14. using namespace std;
  15. int main()
  16. {
  17. int n,m,min,max=0;
  18. cin >> n >> m;
  19.  
  20.  
  21. if (n%m != 0)min = (n / m + n%m) / 2 + ((n / m) / 2)*(m - 1);
  22. else min = ((n / m) / 2)*m;
  23.  
  24. int b = (n - (m - 1)) / 2;
  25. while (b - 1 > 0){max += (b - 1);
  26. b--;
  27. }
  28. if (b % 2 == 1)max++;
  29.  
  30. cout << min << " " << max<<endl;
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3472KB
stdin
5 1
stdout
2 2