Пример #1
0
 static void Main(string[] args)
 {
     string s = Console.ReadLine();
     string t = Console.ReadLine();
     BigInteger a = new BigInteger(s), b = new BigInteger(t);
     Console
 }
Пример #2
0
 public static BigInteger operator -(BigInteger a, BigInteger b)
 {
     BigInteger c = new BigInteger();
     c.n = Math.Max(a.n, b.n);
     for (int i = 0; i < c.n; i++)
         c.a[i] = a.a[i] - b.a[i];
     for (int i = 0; i < c.n; i++)
         if (c.a[i] < 0)
         {
             c.a[i] += 10;
             c.a[i + 1]--;
         }
     while (c.a[c.n - 1] == 0 && c.n > 0)
         c.n--;
     return c;
 }
Пример #3
0
 static public BigInteger operator + (BigInteger x, BigInteger y)
 {
     BigInteger c = new BigInteger();
     int carry = 0;
     c.n = Math.Max(x.n, y.n);
     for(int i = 0; i < c.n; ++i)
     {
         c.a[i] = x.a[i] + y.a[i] + carry;
         carry = c.a[i] / 10;
         c.a[i] %= 10; 
     }
     if (carry > 0) c.a[c.n++] = carry;
     while (c.a[c.n - 1] == 0 && c.n > 0)
         c.n--;
     return c;
 }
Пример #4
0
 static public BigInteger operator *(BigInteger x, BigInteger y)
 {
     BigInteger c = new BigInteger();
     c.n = x.n + y.n;
     for (int i = 0; i < x.n; ++i)
     {
         for(int j = 0, carry = 0; j < y.n || carry > 0; ++j)
         {
             c.a[i + j] += x.a[i] * y.a[j] + carry;
             carry = c.a[i + j] / 10;
             c.a[i + j] %= 10;
         }
     }
     while (c.a[c.n - 1] == 0 && c.n > 0)
         c.n--;
     return c;
 }
Пример #5
0
 static void Main(string[] args)
 {
     string s = Console.ReadLine();
     string t = Console.ReadLine();
     BigInteger a = new BigInteger(s), b = new BigInteger(t);
     Console.WriteLine(a + b);
     Console.WriteLine(b * a);
     Console.WriteLine(a - b);
 }