fork download
  1. long long floor_sum(long long n, long long m, long long a, long long b) {
  2. long long ans = 0;
  3. if (a >= m) {
  4. ans += (n - 1) * n * (a / m) / 2;
  5. a %= m;
  6. }
  7. if (b >= m) {
  8. ans += n * (b / m);
  9. b %= m;
  10. }
  11.  
  12. long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
  13. if (y_max == 0) return ans;
  14. ans += (n - (x_max + a - 1) / a) * y_max;
  15. ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
  16. return ans;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty