From f1c124a2d5c5a5ba600d839c0f2beab2f9649ee5 Mon Sep 17 00:00:00 2001 From: hizenberg Date: Fri, 9 Feb 2024 04:24:01 +0000 Subject: [PATCH] Some Changes --- Number Theory/Fast_Multiply.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Number Theory/Fast_Multiply.cpp b/Number Theory/Fast_Multiply.cpp index d38b6c1..d17cf5a 100644 --- a/Number Theory/Fast_Multiply.cpp +++ b/Number Theory/Fast_Multiply.cpp @@ -1,9 +1,19 @@ -int fast_multiply(int a,int b,int c){ - int res=0; - while(b){ - if(b&1)res+=a,res%=c; - a+=a,a%=c; - b>>=1; - } - return res; -} \ No newline at end of file +#include + +using namespace std; + +int binary_multiplication(int a , int b,int M=(int)1e9+7){ + int res = 0; + while( b ){ + if( b&1 ) res += a , res %= M; + a = 2 * a ; a %= M: + b >>= 1; + } + + return res; +} + +int main(){ + + return 0; +}