链接:https://www.nowcoder.com/acm/contest/144/J来源:牛客网 skywalkert, the new legend of Beihang University ACM-ICPC Team, retired this year leaving a group of newbies again. Rumor has it that he left a heritage when he left, and only the one who has at lea…
传送门 题意:提供一个随机生成函数,让你生成n个数,然后问你其中能找到的两个数的最小公倍数 最大 是多少. 思路:可以用nth_element()函数在O(n)下求出前 15 个大的数(当然,100个数也是可以的),暴力枚举这15个数两两求最小公倍数的结果.当然可以用小根堆优先队列,保证队列中有15个最大的数. (雾,由于是随机数,互质的概率大. // #include<bits/stdc++.h> //#include<unordered_map> #include<uno…
题目链接:https://ac.nowcoder.com/acm/contest/886/J 题目大意 略. 分析 见代码. 代码如下 #include <bits/stdc++.h> using namespace std; #define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define Rep(i,n) for (int i = 0; i < (n); ++i) #define For(i,s,t)…
题意: 有n个技能,一开始都是0级,第i个技能从j-1级升到j级,花费$c_{i,j}$,但是花费不一定是正的 所有的技能升到j级时,奖励$d_j$但是奖励也不一定是正的 题解: 用sum[i][j]储存-c[i][j]的前缀和,即技能i升到j级后总共的收益. 再用w[j]储存f[j]的前缀和,代表所有的技能都升到j的收益. 再开一个数组maxxx[i][j]用于储存技能i至少升到j级的收益,即max(sum[i][j~m]). 然后枚举j,计算$w_j+\sum_{i=1}^{n}maxxx[…
牛客多校第3场 J 思维+树状数组+二分 传送门:https://ac.nowcoder.com/acm/contest/883/J 题意: 给你q个询问,和一个队列容量f 询问有两种操作: 0.访问操作,如果询问的name在队列中存在的话,那么就输出队列中name对应的val值,然后将队列中name对应的元素扔到队列的尾部去,否则就直接将该元素插入到队列的尾部去 1.插入操作,得到队列中对应的name元素的v值为k,查询第k+v个元素的v值是多少 题解: 已知,对于插入操作,我们需要很快的查询…
链接:https://www.nowcoder.com/acm/contest/143/J 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 There are n students going to travel. And hotel has two types room:double room and triple room. The price of a double…
链接:https://ac.nowcoder.com/acm/contest/887/H来源:牛客网 题目描述 Given three integers A, B, C. Count the number of pairs <x ,y> (with 1≤x≤Aand1≤y≤B) such that at least one of the following is true: - (x and y) > C - (x xor y) < C   ("and", &q…
链接:https://www.nowcoder.com/acm/contest/144/C来源:牛客网 Oak is given N empty and non-repeatable sets which are numbered from 1 to N. Now Oak is going to do N operations. In the i-th operation, he will insert an integer x between 1 and M to every set inde…
考的其实是同构图的性质: 1.同构图的顶点数,边数相等 2.同构图通过点的映射后邻接矩阵相同 这篇博客讲的很好https://www.jianshu.com/p/c33b5d1b4cd9 本题还需要一步构造的方案,通过最基础的n=4和n=4+1的图的图推广到n=4k和n=4k+1的状态 #include<bits/stdc++.h> using namespace std; #define maxn 2005 int mp[maxn][maxn]; int n,f[maxn]; int mai…
题目传送门:https://www.nowcoder.com/acm/contest/144/J 题意:给一个function,构造n个数,求出其中任意两个的lcm的最大值. 分析:要求最大的lcm,大概分析一下,差不多就在里面的最大的k个里,k^2求出答案. 因为n(1e7),sort会tle,需要一个效率更低的排序来求出前k大. #include<bits/stdc++.h> using namespace std; ; typedef unsigned ui; typedef unsig…