fork(2) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. typedef pair<int,int> ii;
  7. typedef unsigned long long ull;
  8.  
  9. #define X first
  10. #define Y second
  11. #define pb push_back
  12. #define mp make_pair
  13. #define ep emplace_back
  14. #define EL printf("\n")
  15. #define sz(A) (int) A.size()
  16. #define FOR(i,l,r) for (int i=l;i<=r;i++)
  17. #define FOD(i,r,l) for (int i=r;i>=l;i--)
  18. #define fillchar(a,x) memset(a, x, sizeof (a))
  19. #define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  20.  
  21. const int bs = 1e9;
  22. typedef vector<int> BigInt;
  23.  
  24. void Set(BigInt &a) {
  25. while (a.size() > 1 && a.back() == 0) a.pop_back();
  26. }
  27.  
  28. BigInt Int(string s) {
  29. BigInt a;
  30. while (s.size()%9) s = '0'+s;
  31. for (int i=0; i<s.size(); i+=9) {
  32. ll b = 0;
  33. FOR(j,i,i+9-1) b = b*10+(s[j]-'0');
  34. a.insert(a.begin(), b);
  35. }
  36. Set(a);
  37. return a;
  38. }
  39.  
  40. void Print(BigInt a) {
  41. Set(a);
  42. printf("%d", a.size() == 0 ? 0 : a.back());
  43. FOD(i,a.size()-2,0) printf("%09d", a[i]);
  44. EL;
  45. }
  46.  
  47. BigInt operator + (BigInt a, BigInt b) {
  48. BigInt ans;
  49. Set(a);
  50. Set(b);
  51. int c = 0;
  52. for (int i=0; i<max(a.size(),b.size()); i++) {
  53. if (i < a.size()) c += a[i];
  54. if (i < b.size()) c += b[i];
  55. ans.pb(c%bs);
  56. c /= bs;
  57. }
  58. if (c) ans.pb(c);
  59. Set(ans);
  60. return ans;
  61. }
  62.  
  63. BigInt operator - (BigInt a, BigInt b) {
  64. BigInt ans;
  65. Set(a);
  66. Set(b);
  67. int c = 0;
  68. for (int i=0; i<a.size(); i++) {
  69. c += a[i];
  70. if (i < b.size()) c -= b[i];
  71. if (c < 0)
  72. ans.pb(c+bs), c = -1;
  73. else
  74. ans.pb(c), c = 0;
  75. }
  76. Set(ans);
  77. return ans;
  78. }
  79.  
  80. bool operator < (BigInt a, BigInt b) {
  81. if (a.size() != b.size()) return (a.size() < b.size());
  82. FOD(i,a.size()-1,0)
  83. if (a[i] != b[i]) return (a[i] < b[i]);
  84. return false;
  85. }
  86.  
  87. BigInt operator * (BigInt a, BigInt b) {
  88. BigInt ans(a.size()+b.size(), 0);
  89. Set(a);
  90. Set(b);
  91. FOR(i,0,a.size()-1) {
  92. int c = 0;
  93. FOR(j,0,b.size()-1) {
  94. ll s = (ll)ans[i+j] + c + (ll)a[i]*b[j];
  95. ans[i+j] = s%bs;
  96. c = s/bs;
  97. }
  98. if (c) ans[i+b.size()] = c;
  99. }
  100. Set(ans);
  101. return ans;
  102. }
  103.  
  104. int main() {
  105.  
  106.  
  107. string s;
  108. BigInt a, b;
  109. getline(cin, s);
  110. a = Int(s);
  111. getline(cin, s);
  112. b = Int(s);
  113. Print(a+b);
  114. if (a < b) {
  115. printf("-");
  116. Print(b-a);
  117. } else Print(a-b);
  118. Print(a*b);
  119.  
  120. return 0;
  121. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
Main.java:5: error: class, interface, or enum expected
typedef long long ll;
^
Main.java:6: error: class, interface, or enum expected
typedef pair<int,int> ii;
^
Main.java:7: error: class, interface, or enum expected
typedef unsigned long long ull;
^
Main.java:9: error: illegal character: '#'
#define X first
^
Main.java:9: error: class, interface, or enum expected
#define X first
        ^
Main.java:10: error: illegal character: '#'
#define Y second
^
Main.java:11: error: illegal character: '#'
#define pb push_back
^
Main.java:12: error: illegal character: '#'
#define mp make_pair
^
Main.java:13: error: illegal character: '#'
#define ep emplace_back
^
Main.java:14: error: illegal character: '#'
#define EL printf("\n")
^
Main.java:15: error: illegal character: '#'
#define sz(A) (int) A.size()
^
Main.java:16: error: illegal character: '#'
#define FOR(i,l,r) for (int i=l;i<=r;i++)
^
Main.java:16: error: class, interface, or enum expected
#define FOR(i,l,r) for (int i=l;i<=r;i++)
                                ^
Main.java:16: error: class, interface, or enum expected
#define FOR(i,l,r) for (int i=l;i<=r;i++)
                                     ^
Main.java:17: error: illegal character: '#'
#define FOD(i,r,l) for (int i=r;i>=l;i--)
^
Main.java:17: error: class, interface, or enum expected
#define FOD(i,r,l) for (int i=r;i>=l;i--)
                                ^
Main.java:17: error: class, interface, or enum expected
#define FOD(i,r,l) for (int i=r;i>=l;i--)
                                     ^
Main.java:18: error: illegal character: '#'
#define fillchar(a,x) memset(a, x, sizeof (a))
^
Main.java:19: error: illegal character: '#'
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
^
Main.java:19: error: class, interface, or enum expected
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
                                                 ^
Main.java:19: error: class, interface, or enum expected
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
                                                                ^
Main.java:21: error: class, interface, or enum expected
const int bs = 1e9;
^
Main.java:22: error: class, interface, or enum expected
typedef vector<int> BigInt;
^
Main.java:24: error: class, interface, or enum expected
void Set(BigInt &a) {
^
Main.java:26: error: class, interface, or enum expected
}
^
Main.java:30: error: class, interface, or enum expected
	while (s.size()%9) s = '0'+s;
	^
Main.java:31: error: class, interface, or enum expected
	for (int i=0; i<s.size(); i+=9) {
	^
Main.java:31: error: class, interface, or enum expected
	for (int i=0; i<s.size(); i+=9) {
	              ^
Main.java:31: error: class, interface, or enum expected
	for (int i=0; i<s.size(); i+=9) {
	                          ^
Main.java:33: error: class, interface, or enum expected
		FOR(j,i,i+9-1) b = b*10+(s[j]-'0');
		^
Main.java:34: error: class, interface, or enum expected
		a.insert(a.begin(), b);
		^
Main.java:35: error: class, interface, or enum expected
	}
	^
Main.java:37: error: class, interface, or enum expected
	return a;
	^
Main.java:38: error: class, interface, or enum expected
}
^
Main.java:42: error: class, interface, or enum expected
	printf("%d", a.size() == 0 ? 0 : a.back());
	^
Main.java:43: error: class, interface, or enum expected
	FOD(i,a.size()-2,0) printf("%09d", a[i]);
	^
Main.java:44: error: class, interface, or enum expected
	EL;
	^
Main.java:45: error: class, interface, or enum expected
}
^
Main.java:49: error: class, interface, or enum expected
	Set(a);
	^
Main.java:50: error: class, interface, or enum expected
	Set(b);
	^
Main.java:51: error: class, interface, or enum expected
	int c = 0;
	^
Main.java:52: error: class, interface, or enum expected
	for (int i=0; i<max(a.size(),b.size()); i++) {
	^
Main.java:52: error: class, interface, or enum expected
	for (int i=0; i<max(a.size(),b.size()); i++) {
	              ^
Main.java:52: error: class, interface, or enum expected
	for (int i=0; i<max(a.size(),b.size()); i++) {
	                                        ^
Main.java:54: error: class, interface, or enum expected
		if (i < b.size()) c += b[i];
		^
Main.java:55: error: class, interface, or enum expected
		ans.pb(c%bs);
		^
Main.java:56: error: class, interface, or enum expected
		c /= bs;
		^
Main.java:57: error: class, interface, or enum expected
	}
	^
Main.java:59: error: class, interface, or enum expected
	Set(ans);
	^
Main.java:60: error: class, interface, or enum expected
	return ans;
	^
Main.java:61: error: class, interface, or enum expected
}
^
Main.java:65: error: class, interface, or enum expected
	Set(a);
	^
Main.java:66: error: class, interface, or enum expected
	Set(b);
	^
Main.java:67: error: class, interface, or enum expected
	int c = 0;
	^
Main.java:68: error: class, interface, or enum expected
	for (int i=0; i<a.size(); i++) {
	^
Main.java:68: error: class, interface, or enum expected
	for (int i=0; i<a.size(); i++) {
	              ^
Main.java:68: error: class, interface, or enum expected
	for (int i=0; i<a.size(); i++) {
	                          ^
Main.java:70: error: class, interface, or enum expected
		if (i < b.size()) c -= b[i];
		^
Main.java:71: error: class, interface, or enum expected
		if (c < 0)
		^
Main.java:73: error: class, interface, or enum expected
		else
		^
Main.java:75: error: class, interface, or enum expected
	}
	^
Main.java:77: error: class, interface, or enum expected
	return ans;
	^
Main.java:78: error: class, interface, or enum expected
}
^
Main.java:82: error: class, interface, or enum expected
	FOD(i,a.size()-1,0)
	^
Main.java:84: error: class, interface, or enum expected
	return false;
	^
Main.java:85: error: class, interface, or enum expected
}
^
Main.java:89: error: class, interface, or enum expected
	Set(a);
	^
Main.java:90: error: class, interface, or enum expected
	Set(b);
	^
Main.java:91: error: class, interface, or enum expected
	FOR(i,0,a.size()-1) {
	^
Main.java:93: error: class, interface, or enum expected
		FOR(j,0,b.size()-1) {
		^
Main.java:95: error: class, interface, or enum expected
			ans[i+j] = s%bs;
			^
Main.java:96: error: class, interface, or enum expected
			c = s/bs;
			^
Main.java:97: error: class, interface, or enum expected
		}
		^
Main.java:99: error: class, interface, or enum expected
	}
	^
Main.java:101: error: class, interface, or enum expected
	return ans;
	^
Main.java:102: error: class, interface, or enum expected
}
^
Main.java:108: error: class, interface, or enum expected
	BigInt a, b;
	^
Main.java:109: error: class, interface, or enum expected
	getline(cin, s);
	^
Main.java:110: error: class, interface, or enum expected
	a = Int(s);
	^
Main.java:111: error: class, interface, or enum expected
	getline(cin, s);
	^
Main.java:112: error: class, interface, or enum expected
	b = Int(s);
	^
Main.java:113: error: class, interface, or enum expected
	Print(a+b);
	^
Main.java:114: error: class, interface, or enum expected
	if (a < b) {
	^
Main.java:116: error: class, interface, or enum expected
		Print(b-a);
		^
Main.java:117: error: class, interface, or enum expected
	} else Print(a-b);
	^
Main.java:118: error: class, interface, or enum expected
	Print(a*b);
	^
Main.java:120: error: class, interface, or enum expected
	return 0;
	^
Main.java:121: error: class, interface, or enum expected
}
^
90 errors
stdout
Standard output is empty