Misaki's Kiss again  Accepts: 75  Submissions: 593  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 摩天轮后,一些朋友希望再次得到Misaki的吻,所以Misaki把他们分别编号从1到NN,如果他们中有人的编号是MM,而且gcd(N,M)=Ngcd(N,M)=N xor MM,那么他以可以得到一个吻. 请帮助Misaki…
题意: 给一个数N. 如果GCD(N,M) = N XOR M,则称M是一个kiss   1<=M<=N 问总共有多少个kiss.并且列出所有的值. 思路: 思路一:枚举M.有大量的GCD(N,M)值相等.但是N XOR M=X.当X是定值是,M一定只有一个.所以这个方法明显有大量重复. 发现知道GCD(N,M)的值,可直接求出M.搞定. 令gcd(n,m)=d,可知道d是n的约数 有d=(n xor m)=(m xor n),所以m=(d xor n). 可发现gcd(n,(d xor n)…
Misaki's Kiss again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1621    Accepted Submission(s): 414 Problem Description After the Ferries Wheel, many friends hope to receive the Misaki's kis…
Misaki's Kiss again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1773    Accepted Submission(s): 459 After the Ferries Wheel, many friends hope to receive the Misaki's kiss again,so Misaki nu…
HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/G 题目: Description There is a hill with n holes around. The holes are signed from 0 to n-1.        A rabbit must hide in one of the holes…
Least Common Multiple Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 53016    Accepted Submission(s): 20171 Problem Description The least common multiple (LCM) of a set of positive integers is…
[题目] The sum of gcd Problem Description You have an array A,the length of A is nLet f(l,r)=∑ri=l∑rj=igcd(ai,ai+1....aj) Input There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each…
GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2024    Accepted Submission(s): 904 Problem Description Given two positive integers G and L, could you tell me how many solutions of (…
题目链接 题意 现有\[x+y=a\\lcm(x,y)=b\]找出满足条件的正整数\(x,y\). \(a\leq 2e5,b\leq 1e9,数据组数12W\). 思路 结论 \(gcd(x,y)=gcd((x+y),lcm(x,y))\) 证明 先证\(gcd(x,y)|gcd((x+y),lcm(x,y))\) 不妨设\(gcd(x,y)=k\),则有\(k\mid x,k\mid y\),则有\(k\mid (x+y)\) -① 又\(k\mid x,x\mid lcm(x,y)\),所…
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map of infinite rows and columns. Rows are numbered 1,2,⋯from the bottom, so are the columns. At first the frog is sit…
我想了很久了,后来还是把N分解质因数,枚举各种组合,反正也不多吧,按题目条件,然后就过了. #include <cstdio> #include <iostream> #include <cstring> #include <cctype> #include <algorithm> #define LL __int64 using namespace std; LL prime[100010],np; int fac[100010],nf; in…
Frogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1509    Accepted Submission(s): 498 Problem Description  to m−1 and the frogs are numbered from 1 to n. The i-th frog can jump over exactly …
题意:去除数列中的一个数字,使去除后数列中所有数字的gcd尽可能大. 分析:这个题所谓的Coprime Sequence,就是个例子而已嘛,题目中没有任何语句说明给定的数列所有数字gcd一定为1→_→,队友这样解读题目导致我们队的思路完全想歪了,当时真的脑子发懵,为啥没再读一遍题= = 1.求出一个数列的gcd跟计算顺序没关系. 2.如果求去掉下标为i的数字后整个数列的gcd,直接将该数字前的所有数字的gcd(prefix[i-1])和该数字后所有数字的gcd(suffix[i+1])再求一下g…
Problem Description   MZL loves xor very much.Now he gets an array A.The length of A ≤i,j≤n) The xor of an array B is defined as B1 xor B2...xor Bn Input Multiple test cases, the first line contains an integer T(no more than ), indicating the number…
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke split into two personality a and b, they are playing a game. There is a n∗m matrix, each grid of this matrix has a number ci,j. a wants to beat b every time,…
题目链接 题意 给定\(n\)个数,对其每一个子集计算异或和,求第\(k\)小的异或和. 思路 先求得线性基. 同上题,转化为求其线性基的子集的第k小异或和. 结论 记\(n\)个数的线性基为向量组\(B=\{b_0,b_1,b_2,...,b_t\}(有b_i[p_i]=1,p_1\lt p_2\lt ...\lt p_t)\),记\(k\)的二进制表示为向量\(\vec{K}\). 则第\(k\)小异或和为\[\oplus_{\vec{K}[i]=1}b_i\] 即\(k\)的二进制表示中为…
Xor Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 3647    Accepted Submission(s): 1595 Problem Description Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Ze…
MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 800    Accepted Submission(s): 518 Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to…
题意:给定一棵树,有点权a[],有边权. 现在有M次修改点权的操作,输出每次修改后,Σ(a[i]^a[j])*dis(i,j); 思路:因为待修改,我们需要快速得到以及修改一个点到其他所有点的信息. 肯定就是动态点分治了啊. 而异或这个操作没有什么累加的性质,所以每一位拆开单独计算. 根据二进制位置和01区别,先建立14*2点分树.然后每次在同一位置,不同值的树上累加答案. 因为计算dis的过程会重复很多次,所以可以用个dd数组,减少重复统计,然后就用1400ms变成 了960ms. #incl…
目录 题意: 解析 原题描述 字典树动态求Mex @(hdu 6625求两个序列异或最小值的排列) 题意: \(T(100)\)组,每组两个长度为\(n(100000)\)的排列,你可以将\(a[]\)和\(b[]\)随机排列,可以得到\(c[i]=a[i]\)^\(b[i]\),求字典序最小的\(c[]\). 解析 一个显然对的贪心做法: 针对本题 每次两颗字典树同时往下走,如果都有\(0\)或者\(1\)这条路径,就随便同时走\(0\;or\;1\)这条路径,否则只能一个走\(0\),一个走…
1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ memset(cnt,,sizeof(cnt)); int l=strlen(a); ;i<l;i++){ cnt[a[i]]++; } for(int i='a';i<='z';i++){ printf("%c:%d\n",i,cnt[i]); } printf("\n…
昨晚在开赛前5分钟注册的,然后比赛刚开始就掉线我就不想说了(蹭网的下场……),只好用手机来看题和提交,代码用电脑打好再拉进手机的(是在傻傻地用手机打了一半后才想到的办法). 1001,也就是 hdu 5174,题意很难叙述了,自己看题吧,这题有数据溢出的风险,我竟然是AC了一发才发觉的(只过了小数据),幸好后来改后赶紧再交一遍才不至于被人hack,因为需要对数据去重,我不想用数组模拟,便尝试下用 map了,可是我的奇葩 map ( ~′⌒`~),连我自己都感到无语了: #include<cstd…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil Deposit…
专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil DepositsHDU 1495 非常可乐HDU 26…
(这篇我就不信有网站来扣) 这个暑假打算刷刷题啥的 但是写博客好累啊  堆一起算了 隔一段更新一下.  7月27号之前刷的的就不写了 , 写的累 代码不贴了,可以找我要啊.. 2017.8.27update : 开学了终于搞到了550  可还行 *数据结构 *可持久化线段树/主席树 *bzoj3932 [CQOI2015] 任务查询系统 : 比较裸的主席树,任务查分一下就好了  cqoi真良心 *bzoj4026 dC Loves Number Theory :  数论个头啊,对每个数分解质因数…
先发掘性质: 1.xor和gcd均满足交换律与结合率. 2.前缀gcd最多只有O(log)个. 但并没有什么数据结构能同时利用这两个性质,结合Q=10000,考虑分块. 对每块记录这几个信息: 1.块内所有数的gcd与异或和. 2.将块内所有前缀异或和放入一个数组排序. 查询时从前往后遍历每个块: 1.若当前块不使gcd改变,二分查找是否存在答案. 2.若改变,暴力查找答案. 复杂度(设块大小为S,值域为M): 1.修改复杂度$O(S\log S)$ 2.查询复杂度$O(S\log M+\fra…
前缀gcd的变化次数是log的,考虑对每一种gcd查询,问题变为查询一段区间是否存在异或前缀和=x/gcd. 无修改的话显然可以可持久化trie,但这玩意实在没法支持修改.于是考虑分块. 对于每一块将其中所有块内异或前缀和排序.查询时先看这块与上一块相比gcd有没有变化,如果有对其中每个位置暴力查询,否则在排序后的数组中二分.修改时暴力改每一块的前缀gcd及异或和,被修改的块暴力重构排序数组即可. #include<iostream> #include<cstdio> #inclu…
GCD and LCM Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4497 Description Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and…
GCD is Funny 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5902 Description Alex has invented a new game for fun. There are n integers at a board and he performs the following moves repeatedly: He chooses three numbers a, b and c written at the boa…