File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+
3
+ typedef __int128 LInt;
4
+ ostream& operator <<(ostream&cout , LInt number){
5
+ auto toString = [](LInt num){
6
+ auto tenPow18 = 1000000000000000000 ;
7
+ std::string str;
8
+ do {
9
+ long long digits = num % tenPow18;
10
+ auto digitsStr = std::to_string (digits);
11
+ auto leading0s = (digits != num) ? std::string (18 - digitsStr.length (), ' 0' ) : " " ;
12
+ str = leading0s + digitsStr + str;
13
+ num = (num - digits) / tenPow18;
14
+ } while (num != 0 );
15
+ return str;
16
+ };
17
+ cout << toString (number);
18
+ return cout;
19
+ }
20
+
21
+ istream& operator >>(istream&cin , LInt &number){
22
+ string s; cin >> s;
23
+ number = 0 ;
24
+ bool neg_flag =false ;
25
+ for (auto &itr:s){
26
+ if (itr==' -' ){
27
+ neg_flag = true ;
28
+ continue ;
29
+ }
30
+ number *= 10 ;
31
+ number += (itr-' 0' );
32
+ }
33
+ if (neg_flag){
34
+ number*=(-1 );
35
+ }
36
+ return cin;
37
+ }
38
+
39
+
You can’t perform that action at this time.
0 commit comments