Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define ull unsigned long long
- #define D (1LL<<32)
- unsigned long long x;
- int mnozalne(ull a, ull b)
- {
- ull a1=a/D,a0=a%D;
- ull b1=b/D,b0=b%D;
- ull c0,c1,c2;
- c0=a0*b0;
- c1=a0*b1+b0*a1;
- c2=a1*b1;
- if (c2>0) return 0;
- c1+=c0/D;
- c0%=D;
- c2+=c1/D;
- c1%=D;
- return c2==0;
- }
- int main()
- {
- printf("%d\n",mnozalne(143262LL,23523462LL));
- printf("%d\n",mnozalne((1LL<<32),(1LL<<32)));
- printf("%d\n",mnozalne((1LL<<32),(1LL<<32)-1));
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement