题意:定义两个数\(a,b\)是朋友,如果:\(gcd(a,b)\),\(\frac{a}{gcd(a,b)}\),\(\frac{b}{gcd(a,b)}\)能构成三角形,现在给你一个正整数\(n\),问你\(1-n\)中有多少数没有朋友. 题解:首先考虑合数,设\(a=b*c\),\(b\ge c\),\(b\ge 2,c\ge 2\),我们知道:\(gcd(b,b-1)=1\),那么:\(gcd(b*c,(b-1)*c)=c\),则对于:\(b*c\),\((b-1)*c\),\(gcd(…
Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1 C. Jumping Transformers 我会状压 DP! 用 \(dp[x][y][mask]\) 记录到达 \((x,y)\),之前清楚的排骨龙集合为 \(mask\) 的最小耗费. 如果到达 \((x,y)\) 时,本应遭遇的排骨龙没了,那么想想:这只排骨龙是何时遭到放逐? 很自然地设计出状态:\(dp[x][y][len][0/1]\) 表示当前在 \(x\) 行, \(y\…
题意略,题解生成函数练习题,1+(q-ai)x卷积即可,线段树优化(类似分治思想) //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4) //#pragma GCC optimize("unroll-loops") //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("O…
传送门  Problem - 1600J - Codeforces 题目   题意 给定n行m列, 求每个连通块由多少格子组成,并将格子数从大到小排序输出 对于每个格子都有一个数(0~15),将其转化为二进制(四位数),比如1010 表示北为1,不可通:东为0,可通:南为1,不可通:西为0,可通. 即 1表示墙,不可通,四位数字依次表示为北东南西 [注意:比如样例9到14去,只需判断9东边是否可通即可,14不用管] 题解 差不多和dfs的板子一样~ AC代码 #include <iostream…
Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robots 对\(r\)从大到小排序,然后cdq分治. 注意要对\(q-k,q+k,q\)进行离散化 B. Space Isaac 对原序列做差分,b[i]=a[i]-a[i-1] 如果我们要凑出\(x\),那么集合A中小于\(x\)的数字,要关于\(x/2\)对称,大于\(x\)的数字要关于\((x+m…
B. Neural Network country time limit per test 2 seconds memory limit per test 256 megabytes Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with ma…
题目链接: http://codeforces.com/contest/575/problem/B 题解: 把链u,v拆成u,lca(u,v)和v,lca(u,v)(v,lca(u,v)是倒过来的).这样就只要考虑自下而上的线性结构了,可以用前缀和的思想来做成段更新. 代码: #include<cstdio> #include<vector> #include<cstring> #include<iostream> #include<algorithm…
H. Bots Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/H Description Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are…
D. Tablecity Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/D Description There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief o…
F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Description Bananistan is a beautiful banana republic. Beautiful women in beautiful dresses. Beautiful statues of beautiful warlords. Beautiful stars in…