fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long mul(long long a, long long b, long long p) {
  5. long long k = (long long)((long double)a * b / p + 0.5);
  6. return a * b - k * p;
  7. }
  8.  
  9.  
  10. int main() {
  11. long long m = 1e11 + 7;
  12.  
  13. long long a = 1e11 - 1;
  14. long long b = mul(a, a, m);
  15. cout << b << endl; //correct
  16.  
  17. long double c = a;
  18. long double d = fmod(c * c, m);
  19. cout << d << endl; //wrong
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
64
63