SHARE
TWEET

Untitled

a guest Apr 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct Bint {
  5.     int m[2000];
  6.    
  7.     Bint operator + (Bint k) {
  8.         int ans[1100];
  9.     for (int i=0;i<1000;i++) { if (k.m[i]+m[i]<10) ans[i]+=k.m[i]+m[i]; else { ans[i]+=k.m[i]+m[i]-10; ans[i+1]+=1; }
  10.     ans[i+1]+=ans[i]/10;
  11.     ans[i]%=10;
  12.     }
  13.     Bint qq;
  14.     for (int i=0;i<1000;i++) qq.m[i]=ans[i];
  15.     return qq;
  16. };
  17.  
  18. Bint operator * (Bint k) {
  19.     int ans[1100];
  20.     for (int i=0;i<500;i++) {
  21.         for (int j=0;j<500;j++) {
  22.             ans[i+j]+=m[i]*k.m[j];
  23.         }
  24.     }
  25.     for (int i=0;i<1099;i++) { ans[i+1]+=ans[i]/10; ans[i]%=10; }
  26.     Bint qq;
  27.     for (int i=0;i<1000;i++) qq.m[i]=ans[i];
  28.     return qq;
  29. };
  30.  
  31.  
  32. };
  33. int main() {
  34.     Bint a;
  35.     Bint b;
  36.     a.m[0]=1;
  37.     b.m[0]=2;
  38.     Bint c=a*b;
  39.     for (int i=0;i<10;i++) cout<<c.m[i]<<" ";
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top