Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize ("O3")
- #pragma GCC target ("sse4")
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> pii;
- typedef pair<string,int> psi;
- typedef vector<int> vi;
- typedef vector<string> vs;
- typedef vector<ll> vll;
- typedef vector<vector<int>> vvi;
- typedef vector<vector<string>> vvs;
- typedef vector<vector<ll>> vvll;
- #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
- #define FORd(i,b,a) for (int i =b; i >= a; i--)
- #define sz(x) (int)(x).size()
- #define mp make_pair
- #define pb push_back
- #define f first
- #define s second
- #define ins insert
- const int MOD = 1000000007;
- //type functions here
- int m(ll k)
- {
- return k%MOD;
- }
- string resize(string x,int count)
- {
- while(count--)
- {
- x="0"+x;
- }
- return x;
- }
- int main() {
- int tc=1;
- //cin>>tc;
- FOR(i,1,tc){
- string a="1",b="11";
- int m=a.length()-1,n=b.length()-1;
- if(m<n) {a=resize(a,n-m);m=n;}
- if(n<m) {b=resize(b,m-n);n=m;}
- int carry=0;
- string ans="";
- while(m!=-1||n!=-1)
- {
- if(a[m]=='0'&&b[n]=='0')
- {
- ans=to_string(0+carry)+ans;
- carry=0;
- }
- else if(a[m]=='1'&&b[n]=='1')
- {
- ans=to_string(0+carry)+ans;
- carry=1;
- }
- else
- {
- if(carry)
- {
- ans=to_string(0)+ans;
- }
- else
- {
- ans=to_string(1)+ans;
- }
- }
- cout<<ans<<endl;
- m--;
- n--;
- }
- if(carry) ans=to_string(carry)+ans ;
- cout<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement