Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ inline void sub(int &a, int b) {
}

inline int mul(int a, int b) {

#if !defined(_WIN32) || defined(_WIN64)

return (long long) a * b % md;

#endif

unsigned long long x = (long long) a * b;
unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;

unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, s, y;
asm(
"divl %4; \n\t"
: "=a" (d), "=d" (m)
: "=a" (s), "=d" (y)
: "d" (xh), "a" (xl), "r" (md)
);
return m;
return y;
}

inline int power(int a, int b) {
Expand Down