Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1
Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
{"id":125,"date":"2011-10-24T11:41:44","date_gmt":"2011-10-24T05:41:44","guid":{"rendered":"http:\/\/ujjalruet.wordpress.com\/?p=125"},"modified":"2015-02-13T13:27:30","modified_gmt":"2015-02-13T13:27:30","slug":"bigint-by-jan-vai","status":"publish","type":"post","link":"https:\/\/blog.ujjal.net\/?p=125","title":{"rendered":"BigInt by Jan vai"},"content":{"rendered":"\r\n\/**\r\n*Author : Jan\r\n*Problem Name : Big int for contest\r\n*Algorithm :\r\n*Complexity :\r\n**\/\r\n\r\n#include <cstdio>\r\n#include <string>\r\n#include <cstring>\r\n#include <algorithm>\r\n#include<iostream>\r\nusing namespace std;\r\n\r\nstruct Bigint {\r\nstring a;\r\nint sign;\r\n\r\nBigint() {}\r\nBigint( string b ) { (*this) = b; }\r\nint size() { return a.size(); }\r\nBigint inverseSign() { sign *= -1; return (*this); }\r\nBigint normalize( int newSign ) {\r\nsign = newSign;\r\nfor( int i = a.size() - 1; i > 0 && a[i] == '0'; i-- ) a.erase(a.begin() + i);\r\nif( a.size() == 1 && a[0] == '0' ) sign = 1;\r\nreturn (*this);\r\n}\r\nvoid operator = ( string b ) {\r\na = b[0] == '-' ? b.substr(1) : b;\r\nreverse( a.begin(), a.end() );\r\nthis->normalize( b[0] == '-' ? -1 : 1 );\r\n}\r\nbool operator < ( const Bigint &b ) const {\r\nif( a.size() != b.a.size() ) return a.size() < b.a.size();\r\nfor( int i = a.size() - 1; i >= 0; i-- ) if( a[i] != b.a[i] ) return a[i] < b.a[i];\r\nreturn false;\r\n}\r\nBigint operator + ( Bigint b ) {\r\nif( sign != b.sign ) return (*this) - b.inverseSign();\r\nBigint c;\r\nfor( int i = 0, carry = 0; i < (int)a.size() || i < (int)b.size() || carry; i++ ) {\r\ncarry += (i < (int)a.size() ? a[i] - 48 : 0) + (i < (int)b.a.size() ? b.a[i] - 48 : 0);\r\nc.a += (carry % 10 + 48);\r\ncarry \/= 10;\r\n}\r\nreturn c.normalize(sign);\r\n}\r\nBigint operator - ( Bigint b ) {\r\nif( sign != b.sign ) return (*this) + b.inverseSign();\r\nif( (*this) < b ) return (b - (*this)).inverseSign();\r\nBigint c;\r\nfor( int i = 0, borrow = 0; i < (int)a.size(); i++ ) {\r\nborrow = a[i] - borrow - (i < b.size() ? b.a[i] : 48);\r\nc.a += borrow >= 0 ? borrow + 48 : borrow + 58;\r\nborrow = borrow >= 0 ? 0 : 1;\r\n}\r\nreturn c.normalize(sign);\r\n}\r\nBigint operator * ( Bigint b ) {\r\nBigint c(\"0\");\r\nfor( int i = 0, k = a[i]; i < (int)a.size(); i++, k = a[i] ) {\r\nwhile(k-- - 48) c = c + b;\r\nb.a.insert(b.a.begin(), '0');\r\n}\r\nreturn c.normalize(sign * b.sign);\r\n}\r\nBigint operator \/ ( Bigint b ) {\r\nif( b.size() == 1 && b.a[0] == '0' ) b.a[0] \/= ( b.a[0] - 48 ) ;\r\nBigint c(\"0\"), d;\r\nfor( int j = 0; j < (int)a.size(); j++ ) d.a += \"0\";\r\nint dSign = sign * b.sign; b.sign = 1;\r\nfor( int i = a.size() - 1; i >= 0; i-- ) {\r\nc.a.insert( c.a.begin(), '0');\r\nc = c + a.substr( i, 1 );\r\nwhile( !( c < b ) ) c = c - b, d.a[i]++;\r\n}\r\nreturn d.normalize(dSign);\r\n}\r\nBigint operator % ( Bigint b ) {\r\nif( b.size() == 1 && b.a[0] == '0' ) b.a[0] \/= ( b.a[0] - 48 ) ;\r\nBigint c(\"0\");\r\nint cSign = sign * b.sign; b.sign = 1;\r\nfor( int i = a.size() - 1; i >= 0; i-- ) {\r\nc.a.insert( c.a.begin(), '0');\r\nc = c + a.substr( i, 1 );\r\nwhile( !( c < b ) ) c = c - b;\r\n}\r\nreturn c.normalize(cSign);\r\n}\r\nvoid print() {\r\nif( sign == -1 ) putchar('-');\r\nfor( int i = a.size() - 1; i >= 0; i-- ) putchar(a[i]);\r\n}\r\n};\r\n\r\nint main() {\r\n\r\nBigint a, b, c;\r\nstring p,q;\r\n\r\ncin>>p>>q;\r\na=p;\r\nb=q;\r\n\r\nc = a + b;\r\n\r\nc.print();\r\n\r\nputchar('\\n');\r\n\r\nc = a - b;\r\nc.print();\r\nputchar('\\n');\r\n\r\nc = a * b;\r\nc.print();\r\nputchar('\\n');\r\n\r\nc = a \/ b;\r\nc.print();\r\nputchar('\\n');\r\n\r\nc = a % b;\r\nc.print();\r\nputchar('\\n');\r\n\r\nreturn 0;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"\/** *Author : Jan *Problem Name : Big int for contest *Algorithm : *Complexity : **\/ #include <cstdio> #include <string> #include <cstring> #include <algorithm> #include<iostream> using namespace std; struct Bigint { string a; int sign; Bigint() {} Bigint( string b ) { (*this) = b; } int size() { return a.size(); } Bigint inverseSign() { … <\/p>\n
Continue reading “BigInt by Jan vai”<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125"}],"version-history":[{"count":12,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":339,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions\/339"}],"wp:attachment":[{"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ujjal.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}