Skip to content

Instantly share code, notes, and snippets.

@vstrimaitis
Created October 15, 2017 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vstrimaitis/5bdde4f6f1816031d9de9f960b935b38 to your computer and use it in GitHub Desktop.
Save vstrimaitis/5bdde4f6f1816031d9de9f960b935b38 to your computer and use it in GitHub Desktop.
OC 2017-10-15
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <climits>
#include <set>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <sstream>
#include <functional>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <complex>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T> using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TESTS(t) int NUMBER_OF_TESTS; cin >> NUMBER_OF_TESTS; for(int t = 1; t <= NUMBER_OF_TESTS; t++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ROF(i, start, end) for(int i = (start); i >= (end); i--)
#define all(x) (x).begin(), (x).end()
//#define endl "\n"
#define PI (asin(1)*2)
#define OO ((1LL<<31)-1)
#define eps 1e-12
#define in(a, b) ((b).find(a) != (b).end())
#define mp(a, b) make_pair((a), (b))
#define sgn(a) ((a) > eps ? 1 : ((a) < -eps ? -1 : 0))
#define cl1(x) ((x)&((x)-1)) // clear lowest 1 bit
#define cl0(x) ((x)|((x)+1)) // clear lowest 0 bit
#define ct1(x) ((x)&((x)+1)) // clear all trailing 1 bits
#define pb push_back
#define MOD 1000000007
#define MAX_N 500001
using namespace std;
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a%b);
}
bool willGoOutOfControl(vector<int>& carry, int idx) {
if (idx + 2 >= carry.size()) return false;
int a = carry[carry.size() - 1];
int b = carry[carry.size() - 2];
int c = carry[carry.size() - 3];
int g = gcd(a, gcd(b, c));
a /= g;
b /= g;
c /= g;
return a%2==1 && b%2==0 && c%2==0;
}
int main()
{
FAST_IO
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
string s1, s2;
cin >> s1 >> s2;
if (s2.length() > s1.length()) {
swap(s1, s2);
}
/*while (s2.length() != s1.length()) {
s2 = "0" + s2;
}*/
reverse(s1.begin(), s1.end());
reverse(s2.begin(), s2.end());
//string ans = "";
list<char> ans;
vector<int> carry;
carry.pb(0);
int idx;
FOR(i, 0, s1.length()) {
idx = i;
int a = s1[i] - '0';
int b = (i < s2.length() ? s2[i] - '0' : 0);
int s = a + b + carry[i];
if (s < 2) {
//ans += s + '0';
ans.push_back(s+'0');
if (i == carry.size() - 1) {
carry.pb(0);
}
}
else {
//ans += (s % 2) + '0';
ans.pb((s % 2) + '0');
int cnt = s / 2;
if (i == carry.size() - 1) {
carry.pb(0);
}
if (i + 1 == carry.size() - 1) {
carry.pb(0);
}
if (i + 2 == carry.size() - 1) {
carry.pb(0);
}
carry[i + 1] += cnt * 0;
carry[i + 2] += cnt * 1;
carry[i + 3] += cnt * 1;
}
}
idx++;
int init = idx;
int zeros = 0;
for (; idx < carry.size(); idx++) {
if (/*willGoOutOfControl(carry, init) || */zeros > 100) {
break;
}
int a = 0;
int s = a + carry[idx];
if (s == 0 && idx == carry.size() - 1) break;
if (s < 2) {
//ans += s + '0';
ans.pb(s + '0');
if (s == 0) zeros++;
else zeros = 0;
}
else {
//ans += (s % 2) + '0';
ans.pb((s % 2) + '0');
if (s % 2 == 0) zeros++;
else zeros = 0;
int cnt = s / 2;
if (idx == carry.size() - 1) {
carry.pb(0);
}
if (idx + 1 == carry.size() - 1) {
carry.pb(0);
}
if (idx + 2 == carry.size() - 1) {
carry.pb(0);
}
carry[idx + 1] += cnt * 0;
carry[idx + 2] += cnt * 1;
carry[idx + 3] += cnt * 1;
}
}
while (ans.size() > 0 && ans.back() == '0') {
ans.pop_back();
}
if (ans.size() == 0) {
cout << 0 << endl;
}
else {
reverse(ans.begin(), ans.end());
for (auto c : ans) {
cout << c;
}
cout << endl;
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <climits>
#include <set>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <sstream>
#include <functional>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <complex>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T> using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TESTS(t) int NUMBER_OF_TESTS; cin >> NUMBER_OF_TESTS; for(int t = 1; t <= NUMBER_OF_TESTS; t++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ROF(i, start, end) for(int i = (start); i >= (end); i--)
#define all(x) (x).begin(), (x).end()
//#define endl "\n"
#define PI (asin(1)*2)
#define OO ((1LL<<31)-1)
#define eps 1e-12
#define in(a, b) ((b).find(a) != (b).end())
#define mp(a, b) make_pair((a), (b))
#define sgn(a) ((a) > eps ? 1 : ((a) < -eps ? -1 : 0))
#define cl1(x) ((x)&((x)-1)) // clear lowest 1 bit
#define cl0(x) ((x)|((x)+1)) // clear lowest 0 bit
#define ct1(x) ((x)&((x)+1)) // clear all trailing 1 bits
#define pb push_back
#define MOD 1000000007
#define MAX_N 600
using namespace std;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11,0,17,51,37,75,202,185,248,259,255,173,102,46,24,9,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,19,29,55,122,213,250,329,374,321,283,200,123,55,12,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,12,0,19,60,43,90,261,292,386,490,564,433,330,200,121,62,21,8,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,20,30,58,150,263,370,503,657,701,685,523,401,237,114,60,13,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,13,0,20,71,47,107,321,397,602,812,1035,951,865,624,455,267,123,49,21,5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,21,32,61,175,323,480,729,1069,1213,1427,1270,1052,774,494,284,133,36,10,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,14,0,22,82,50,119,399,499,825,1229,1751,1856,1851,1582,1388,893,572,243,139,50,6,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,22,35,63,200,372,591,1006,1540,1977,2506,2716,2497,2054,1520,1066,579,283,106,39,14,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,15,0,23,95,52,130,469,634,1055,1718,2661,3235,3631,3472,3405,2493,1899,1108,611,270,114,39,14,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,23,36,66,213,428,693,1277,2105,2979,4116,4873,5173,4835,4082,3121,2091,1262,566,304,100,30,9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,16,0,25,108,55,140,544,772,1295,2241,3779,5120,6288,6733,7345,6286,5259,3578,2331,1261,654,302,116,38,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,24,38,67,228,470,789,1568,2691,4207,6248,8076,9292,10062,9441,8195,6116,4283,2540,1411,639,259,91,32,5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,17,0,26,123,57,149,606,918,1535,2775,5062,7484,10063,11941,13993,13622,12737,10066,7451,4650,2798,1459,669,259,90,28,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,25,39,70,237,510,880,1844,3362,5487,8840,12402,15713,18508,19225,18704,15759,12511,8640,5448,2955,1419,638,251,62,20,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,18,0,28,138,59,154,683,1049,1761,3372,6440,10342,14794,19291,24574,26678,27352,24125,20238,14560,9929,5918,3245,1437,632,257,58,30,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,26,40,71,249,552,964,2116,3973,6923,11777,17839,24419,31161,35769,38168,36233,31516,24602,17636,11094,6341,3249,1488,594,224,69,12,6,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,19,0,29,155,60,163,752,1201,1972,3934,7893,13479,20706,29076,39624,47624,52997,51977,48370,39308,29568,20318,12570,6745,3410,1517,592,190,67,12,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,27,41,73,259,586,1039,2333,4584,8408,15027,24203,35657,48980,61370,70776,73917,71166,61695,49246,35210,23147,13603,7264,3365,1494,529,172,48,13,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,20,0,31,172,62,169,832,1345,2161,4501,9392,16828,27411,41085,60172,78231,94408,102051,103375,93040,78390,59373,42003,25607,14784,7425,3560,1456,545,187,41,9,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,28,43,75,266,621,1099,2531,5205,9816,18406,31342,49148,72276,97566,121866,138034,145259,138908,121820,97347,71258,47526,28944,15733,7839,3485,1386,456,138,43,11,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,21,0,32,191,64,177,896,1509,2333,5023,10830,20309,34926,55332,86259,120262,156256,183102,201412,199383,184745,154720,120321,83655,54131,31240,16776,8051,3415,1323,467,129,34,9,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,29,44,77,275,652,1152,2716,5718,11105,21855,39092,64799,101109,145815,195273,238707,272301,283526,272208,239578,193853,143658,98241,60485,34252,17352,8094,3234,1196,400,122,30,9,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,22,0,34,210,66,184,980,1678,2473,5473,12223,23928,42780,71104,117295,174975,242480,305890,363024,390899,393949,361662,308987,237470,170994,110954,67179,36631,18248,7817,3378,1152,390,102,37,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,30,45,78,283,682,1193,2898,6148,12402,25307,47032,81491,135109,206681,294599,387150,473481,533212,555142,533192,473502,385455,290326,199209,126702,72962,38716,18276,7937,3080,1122,369,88,25,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,23,0,35,231,67,191,1049,1870,2595,5919,13525,27444,50839,88248,152754,241736,355727,480922,610971,709932,770732,768658,714208,605735,478339,345135,231429,140886,79473,39529,18732,7899,3053,1004,347,79,28,5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,31,46,80,290,713,1229,3052,6558,13475,28460,55138,99528,173252,279494,421721,590808,772602,932349,1048116,1088643,1048679,931007,767779,581912,408295,262577,155650,84206,41650,18802,7608,2802,915,302,72,16,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,24,0,37,252,69,196,1143,2056,2710,6308,14754,30989,58772,105749,191727,319951,498003,714780,967286,1202134,1401515,1509519,1514507,1398231,1202059,953722,701564,473028,296832,168322,89584,42688,18904,7428,2637,860,272,66,18,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,32,47,81,298,745,1259,3191,6901,14495,31434,62616,117903,214138,362948,576879,856768,1189558,1533361,1843149,2058333,2138082,2056961,1839030,1525034,1171497,829114,544029,328981,182528,93480,43488,18542,7216,2523,801,207,63,10,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,25,0,38,275,71,202,1217,2272,2806,6672,15866,34337,66474,123450,232776,407879,667037,1013167,1449930,1920436,2389245,2757319,2973365,2962056,2757412,2377078,1907196,1411910,974636,615058,363002,195094,96707,43870,18388,6764,2402,717,191,51,9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,33,48,83,305,777,1289,3306,7225,15354,34073,69746,136044,256877,454500,758480,1187684,1742791,2382318,3050538,3640762,4049178,4192033,4043343,3631796,3032711,2345136,1687039,1124953,691687,394184,206953,99468,43716,17534,6469,2139,681,164,27,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,26,0,40,298,73,207,1318,2497,2899,6990,16886,37512,73896,140311,275338,502678,860560,1374224,2073140,2910576,3847818,4726771,5446027,5824555,5827628,5423762,4713335,3798415,2857150,1985213,1286040,766167,424901,215849,102008,43377,17436,6095,2020,569,157,34,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,34,49,84,312,809,1315,3412,7479,16103,36456,76409,153081,299842,552282,962617,1580376,2439281,3525357,4781004,6063106,7191681,7963132,8239749,7955930,7171806,6016396,4705372,3423563,2312324,1451445,844812,453081,224137,102600,42878,16522,5662,1781,482,123,26,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,27,0,41,323,74,214,1400,2755,2979,7305,17848,40560,80870,156496,317488,601588,1073789,1795058,2842655,4208837,5880830,7663771,9386973,10710235,11463004,11444692,10701482,9320082,7588477,5741359,4058477,2660101,1624428,916027,479674,230988,103408,41827,15958,5257,1627,471,111,36,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,4,35,50,86,318,841,1343,3515,7736,16726,38521,82428,169220,342114,651659,1182778,2028882,3283152,4989866,7141238,9579057,12049803,14199444,15676328,16197281,15668763,14155834,11956416,9427267,6930291,4750206,3029613,1795035,986412,502376,236069,102731,40778,14784,4861,1474,403,82,23,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,1,0,28,0,43,348,76,219,1509,3017,3052,7608,18753,43532,87217,171443,358520,701897,1300233,2267232,3754350,5835554,8586426,11813396,15318198,18555590,21139108,22523621,22542186,21078072,18475460,15110300,11568351,8255368,5501887,3409347,1969264,1052508,523725,239754,101947,39537,14177,4542,1353,353,89,16,5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,1,2,3,34,47,78,302,812,1217,3272,7245,15712,37013,79895,167875,346736,678366,1266558,2241078,3748388,5903943,8760872,12206114,15974874,19609442,22571394,24339722,24587542,23250873,20552576,16986772,13099723,9429440,6329481,3948081,2289058,1230258,613548,282015,119237,46135,16552,5394,1629,435,106,24,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, },{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }, };
pii lenAnd1Cnt(ll n) {
int cnt1 = 0;
int len = n == 0 ? 1 : 0;
while (n > 0) {
cnt1 += (n & 1);
n >>= 1;
len++;
}
return { len, cnt1 };
}
int main()
{
FAST_IO
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ull n;
cin >> n;
auto info = lenAnd1Cnt(n);
cout << counts[info.first][info.second] << endl;
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <climits>
#include <set>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <sstream>
#include <functional>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <complex>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T> using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TESTS(t) int NUMBER_OF_TESTS; cin >> NUMBER_OF_TESTS; for(int t = 1; t <= NUMBER_OF_TESTS; t++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ROF(i, start, end) for(int i = (start); i >= (end); i--)
#define all(x) (x).begin(), (x).end()
//#define endl "\n"
#define PI (asin(1)*2)
#define OO ((1LL<<31)-1)
#define eps 1e-12
#define in(a, b) ((b).find(a) != (b).end())
#define mp(a, b) make_pair((a), (b))
#define sgn(a) ((a) > eps ? 1 : ((a) < -eps ? -1 : 0))
#define cl1(x) ((x)&((x)-1)) // clear lowest 1 bit
#define cl0(x) ((x)|((x)+1)) // clear lowest 0 bit
#define ct1(x) ((x)&((x)+1)) // clear all trailing 1 bits
#define pb push_back
#define MOD 1000000007
#define MAX_N 600
using namespace std;
int c[20];
int e[20];
int n;
bool used[20];
ll ans = 0;
inline void permute(int k) {
if (k == n) {
ans++;
return;
}
for (int i = 0; i < n; i++) {
if (!used[i] && c[i] <= e[k]) {
used[i] = true;
permute(k + 1);
used[i] = false;
}
}
}
int sameCnt() {
set<int> s;
FOR(i, 0, n) {
s.insert(c[i]);
}
return s.size();
}
int possible[20];
int main()
{
FAST_IO
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin >> n;
FOR(i, 0, n) {
cin >> c[i];
}
FOR(i, 0, n) {
cin >> e[i];
}
sort(c, c + n);
sort(e, e + n);
FOR(i, 0, n) {
FOR(j, 0, n) {
if (c[j] <= e[i]) possible[i]++;
}
}
ll ans = 1;
FOR(i, 0, n) {
ans *= possible[i];
FOR(j, i + 1, n) {
possible[j]--;
}
}
cout << ans << endl;
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <climits>
#include <set>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <sstream>
#include <functional>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <complex>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T> using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TESTS(t) int NUMBER_OF_TESTS; cin >> NUMBER_OF_TESTS; for(int t = 1; t <= NUMBER_OF_TESTS; t++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ROF(i, start, end) for(int i = (start); i >= (end); i--)
#define all(x) (x).begin(), (x).end()
//#define endl "\n"
#define PI (asin(1)*2)
#define OO ((1LL<<31)-1)
#define eps 1e-12
#define in(a, b) ((b).find(a) != (b).end())
#define mp(a, b) make_pair((a), (b))
#define sgn(a) ((a) > eps ? 1 : ((a) < -eps ? -1 : 0))
#define cl1(x) ((x)&((x)-1)) // clear lowest 1 bit
#define cl0(x) ((x)|((x)+1)) // clear lowest 0 bit
#define ct1(x) ((x)&((x)+1)) // clear all trailing 1 bits
#define pb push_back
#define MOD 1000000007
#define MAX_N 100000
using namespace std;
int main()
{
FAST_IO
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
ll total = 0;
FOR(i, 0, n) {
ll a;
cin >> a;
total ^= a;
}
if (total != 0) {
cout << 0 << endl;
return 0;
}
ll ans = (1LL << n) - 2;
cout << ans << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment