Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- ll Add(ll a,ll b){
- while(b){
- ll carry=a&b;
- a=a^b;
- b=carry<<1;
- }
- return a;
- }
- ll Multiply(ll a,ll b){
- ll res=0;
- while(b){
- if(b&1){
- res=Add(res,a);
- }
- a<<=1;
- b>>=1;
- }
- return res;
- }
- int main(){
- ll x,y;
- cin>>x>>y;
- cout<<Multiply(x,y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment