fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n,m ;
  7. cin >> n >> m ;
  8.  
  9. int a = n/m ;
  10. int b = n%m ;
  11. long long z = (long long) a*(a-1)/2*(m-b) + b*a*(a+1)/2 ;
  12. cout << z << ' ' ;
  13.  
  14. n = n+1-m ;
  15. z = (long long) n*(n-1)/2 ;
  16. cout << z ;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 15232KB
stdin
1000000000 1
8
5
111
17
stdout
499999999500000000 499999999500000000