04 2018 档案
摘要:#include #include #include #include using namespace std; const int maxn=1000000; int Q1[maxn]; int Q2[maxn],r1,r2; int sum[maxn],dp[maxn]; int main(){ int n; while(scanf("%d",&n)!=EOF){ ...
阅读全文
摘要:设a[i][j]表示将矩阵压缩成线性序列的前缀和 那么我们在做dp时枚举起点 i 与终点j 最内层枚举行号,那么可以一行一行的累加, 最后更新答案即可
阅读全文
摘要:题意:进制转换,把a进制转换为b进制。 如果数据不大的话,那么这个题还是很简单的,但这个题就是数据范围太大,所以这里可以采用短除法来做。 关于短除法,就是把每一位(这里指的每一位是指个位十位之类的)除以要转换的进制的余数在乘以当前进制的值加到下一位去,当前位的值就为商,然后这样一直进行到最后一位(也
阅读全文
摘要:x坐标排序后-相应第为第几个 若本来就相邻减后值相同 如 2 3 4 8 9 减后 1 1 1 4 4 所以往中位数移就好
阅读全文
摘要:Description 有n个小朋友坐成一圈,每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。 有n个小朋友坐成一圈,每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。 Input 第一行一个正整数n<=1000000,表示小朋友的个数.接下来n
阅读全文
摘要:Corral the Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1196 Accepted: 502 Description Farmer John wishes to build a corral for his
阅读全文
摘要:corral 的翻译 corral 的翻译 corral 的翻译 名词 栈 warehouse, repository, storehouse, pen, poundage, corral 动词 关进畜栏 corral finicky 的翻译 finicky 的翻译 finicky 的翻译 形容词
阅读全文
摘要:4722: 占卜DIY Description lyd学会了使用扑克DIY占卜。方法如下:一副去掉大小王的扑克共52张,打乱后均分为13堆,编号1~13,每堆4张,其中第13堆称作“生命牌”,也就是说你有4条命。这里边,4张K被称作死神。 初始状态下,所有的牌背面朝上扣下。 流程如下: 1.抽取生命
阅读全文
摘要:两个矩阵,排成线性序列,若逆序对奇偶性相同,则可以互相转化矩阵 注意:0不算入内,
阅读全文
摘要:归并排序 1.数组从0开始用 2.二分为(l+1<r) 3.cnt+=mid+j-k-1; 4.递归meger(0,n,a)
阅读全文
摘要:建立一个大根堆与小根堆,大根堆中存(n+1)/2 的元素,中位数即为大根堆堆顶 用一个从大到小排序的优先队列q1来模拟小于x的数。 从小到大排序的优先队列q2来模拟大于x的数。 动态维护两个优先队列的元素个数。q1.size()=q2.size() 输入的数为偶数个时, q1.size()=q2.s
阅读全文
摘要:#include #include #include #include using namespace std; const double nil=1e-5; const int maxn=100000+10; double a[maxn],b[maxn],sum[maxn]; int main(){ //freopen("data.in","r",stdin); //fre...
阅读全文
摘要:转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1309237394 大致题意: 求A^B的所有约数(即因子)之和,并对其取模 9901再输出。 解题思路: 要求有较强 数学思维 的题 应用定理主要有三个: 要求有较强 数学思维 的题 应用定
阅读全文
摘要:4:反复平方法计算幂次式p^n 这是本题关键所在,求n次幂方法的好坏,决定了本题是否TLE。 以p=2,n=8为例 常规是通过连乘法求幂,即2^8=2*2*2*2*2*2*2*2 这样做的要做8次乘法 而反复平方法则不同, 定义幂sq=1,再检查n是否大于0, While,循环过程若发现n为奇数,则
阅读全文
摘要:设一个数为A,分解质因数得A=a1^b1 * a2^b2 * a3^b3 an^bn [a1 a2 a3 .表示不同的质因数 b1 b2 b3 表示每个质因数的次方数(即相同质因数的个数)]则有:A的约数的个数=(1+b1)(1+b2)(1+b3).(1+bn)A的约数的总和=(1+a1+a1^2+
阅读全文
摘要:这是一道典型的利用状态压缩DP求最优Hamilton回路的题目。取dp[state][i][j]表示state状态下倒数第二个岛为i,最后一个岛为j时的最优解,num[state][i][j]为相应的路径数目,其中state的二进制表示的i位为1表示岛i被访问过,反之为0。则显然当有边(i,j)存在
阅读全文
摘要:1.a^b可以写成 a*a*a*a....a(b个a相乘) 而b又可以二进制分解为 b=c*2^k-1+c*2^k-2.....+c*2^0(c为该数在二进制下对应数字) 所以 用b>>1可以舍去b的最低位,而b&1可以求出b的最低位 所以 2.64位整数乘法 求a*b%p
阅读全文
摘要:int compress(int *x1,int *x2,int w){ vector xs; for(int i=0;i<N;i++){ for(int d=-1;d<=1;d++){ int tx1=x1[i]+d,tx2=x2[i]+d; if(1<=tx1&&tx1<=w) xs.push_back(tx1); if(...
阅读全文
摘要:题目限制 时间限制 内存限制 评测方式 题目来源 1000ms 131072KiB 标准比较器 Local 题目描述 学校实行学分制。每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分。学校开设了N(N<300)门的选修课程,每个学生可选课程的数量M是给定的。学生选修了这M门课并考核通过就
阅读全文
摘要:#include<cstdio> #include<algorithm> #include<cstring> using namespace std; long long dp[12][1<<11]; bool ins[1<<11]; int main(){ int n,m; while(scanf
阅读全文
摘要:#include #include #include using namespace std; const int maxn=11000; struct my{ int next; int v; }; bool biao[110][110]; bool vis[maxn]; int match[maxn]; int n,m,adj[maxn],fa; my bian[...
阅读全文
摘要:Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5665 Accepted: 1602 Description Yixght is a manager of the company called SzqNetwor
阅读全文
摘要:#include #include #include #include #include using namespace std; struct my{ int next; int v; }; const int maxn=10000; int adj[maxn],low[maxn],dfsn[maxn],dfn,fa,id[maxn],sadj[maxn],sfa; my bi...
阅读全文
摘要:#include #include #include using namespace std; struct my{ int next; int v; }; const int maxn=10000; int low[maxn],dfsn[maxn],adj[maxn],fa,sfa,dfn; int bs[maxn],cnt; bool bridge[maxn*2]; in...
阅读全文

浙公网安备 33010602011771号