关注
2居然不需要考虑大数??? 不过大数也AC了。。。主办方真的是。。神奇 #include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <string> #include <math.h> #include <stack> #include <queue> #include <vector> #include <map> #include <set> #include <cmath> #pragma warning(disable:4996) #define Zero(a) memset(a, 0, sizeof(a)) #define Neg(a) memset(a, -1, sizeof(a)) #define All(a) a.begin(), a.end() #define PB push_back #define repf(i,a,b) for(i = a;i <= b; i++) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define root 1,n,1 #define ld rt << 1 #define rd rt << 1 | 1 #define ll long long #define MAXN 100100 #define INF 6666666 #define mod 1000000007 #define ll long long #define sqrtt(x) (ll)(x)*(x) #define dist(x1,y1,x2,y2) (sqrtt(x1-x2)+sqrtt(y1-y2)) using namespace std; ll x, y; ll k; int T; int yess[130]; vector<int>rec; string Sum(string s1, string s2) { if (s1.length() < s2.length()) { string temp = s1; s1 = s2; s2 = temp; } int i, j; for (i = s1.length() - 1, j = s2.length() - 1; i >= 0; i--, j--) { s1[i] = char(s1[i] + (j >= 0 ? s2[j] - '0' : 0)); if (s1[i] - '0' >= 10) { s1[i] = char((s1[i] - '0') % 10 + '0'); if (i) s1[i - 1]++; else s1 = '1' + s1; } } return s1; } ll multt(ll m, ll n) { ll ans = 1; for (int i = 0; i < n; ++i) ans *= m; return ans; } string Multiply(string s, int x) //大数乘以整形数 { reverse(s.begin(), s.end()); int cmp = 0; for (int i = 0; i < s.size(); i++) { cmp = (s[i] - '0')*x + cmp; s[i] = (cmp % 10 + '0'); cmp /= 10; } while (cmp) { s += (cmp % 10 + '0'); cmp /= 10; } reverse(s.begin(), s.end()); return s; } struct node { int val; int pos; }; vector<node>nd; int main() { while (cin >> T) { while (T--) { cin >> x >> k; rec.clear(); for (int i = 0; i < 130; ++i) yess[i] = 1; ll tt = 0; int stp = 0; while (tt <= x) { if (multt(2, stp) & x) { yess[stp] = 0; } tt += multt(2, stp); stp++; } nd.clear(); int cnt = 0; for (int i = 0; i < 130; ++i) { node kk; if (yess[i] == 1) { kk.pos = 1; kk.val = i; nd.push_back(kk); } } //cout << nd.size() << endl; stp = 0; tt = 0; while (stp < nd.size()) { if ((multt(2, stp) & k) && tt <= k) { nd[stp].pos = 1; } else { nd[stp].pos = 0; } tt += multt(2, stp); stp++; } vector<node>ndd; for (int i = 0; i < nd.size(); ++i) { if (nd[i].pos == 1) ndd.push_back(nd[i]); } string ans = "0"; for (int i = 0; i < ndd.size(); ++i) { string anss = "1"; for (int j = 0; j < ndd[i].val; ++j) anss = Multiply(anss, 2); //cout << anss << endl; ans = Sum(ans, anss); } cout << ans << endl; } } return 0; }
查看原帖
点赞 5
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 秋招开始捡漏了吗 #
39012次浏览 275人参与
# 找工作八股要背到什么程度? #
5947次浏览 100人参与
# 京东开奖 #
435904次浏览 2467人参与
# 今年秋招是回暖还是遇冷 #
5512次浏览 40人参与
# 我来点评面试官 #
1860次浏览 20人参与
# 你实习是赚钱了还是亏钱了? #
8499次浏览 78人参与
# 用一句话形容你的团队氛围 #
5025次浏览 76人参与
# 你找工作是从容有余 or 匆忙滚爬? #
4099次浏览 46人参与
# 上班后,才发现大学__白学了 #
6838次浏览 41人参与
# 考研人,我有话说 #
149750次浏览 1198人参与
# 同bg的你秋招战况如何? #
161865次浏览 940人参与
# 今年秋招还有金九银十吗 #
27685次浏览 253人参与
# 58同城求职进展汇总 #
38270次浏览 260人参与
# 实习教会我的事 #
34716次浏览 301人参与
# 打工人的精神状态 #
104346次浏览 1323人参与
# 辞职后的日常 #
17215次浏览 84人参与
# 秋招后遗症 #
66756次浏览 422人参与
# 规定下班时间vs实际下班时间 #
57598次浏览 333人参与
# 一人一个landing小技巧 #
129474次浏览 1467人参与
# 学历对求职的影响 #
553396次浏览 3926人参与
# 机械人,你的第一份感谢信是谁给的 #
37572次浏览 346人参与
