题目链接:https://nanti.jisuanke.com/t/30999 参考自博客:https://kuangbin.github.io/2018/09/01/2018-ACM-ICPC-Nanjing-online-J/ 题目中文: 1000毫秒 512000K 无方形整数是一个整数,除了1以外的任何平方数都不可分 这个数.例如,6 = 2 *3,6=2*3,6是无方形整数,但12 = 2 ^ 2*3,,因为2 ^ 2是正方形数.有些整数可以分解为两个无方形整数的乘积,可能有多种分解方…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 线性筛求出每个数的最小质因子x for 从1-n 对于i,它的最小质因子为x 考虑i=ab 如果i能被x^3整除 那么这x怎么分配给它的两个因子a,b都不行,(都有一个因子会分配至少2个以上,那么我们提出来一个x^2的话,a或b就能被x^2整除了).所以ans[i] = 0 如果i能被x^2整除(先判断x^3再判断x^2这样能保证x就只能被x^2整除),那么ans[i] = ans[i/(x^2)] 因为这个x显然只能分到两边去…
A square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 \cdot 36=2⋅3 is square-free, but 12 = 2^2 \cdot 312=22⋅3 is not, because 2^222 is a square number. Some integers could be decomposed into prod…
ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems. However, he can submit ii-th problem if and only if he has s…
J. Sum 26.87% 1000ms 512000K   A square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 \cdot 36=2⋅3 is square-free, but 12 = 2^2 \cdot 312=22⋅3 is not, because 2^222 is a square number. Some integer…
Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there are ii candies in the i^{th}ith box, each cand…
https://www.jisuanke.com/contest/1555?view=challenges 题意: 题解:写完都没发现是个积性函数233 想法就是对x分解质因数,f(x)就是2^k,其中k是x分解结果中次数为一的质因子个数.如果有某个次数大于等于3,f(x)==0; 这样明显会TLE 所以就想一个递推的方法. 于是魔改了一下线性筛. #include<iostream> #include<cstdlib> #include<cstdio> #includ…
https://nanti.jisuanke.com/t/30999 题意 f(i)表示i能拆分成两个数的乘积,且要求这两个数中各自都没有出现超过1次的质因子的方案数.每次给出n,求∑(n,i=1)f(i) 分析 n到2e7,肯定得打表离线做. 类似打欧拉函数表的方式,对于数d以及素数p,f(p)=2:当d|p时,若d|p^2,则f(d∗p)=0:否则f(d∗p)=f(d)/2;当d†p时,f(d∗p)=f(d)∗2 #include<bits/stdc++.h> using namespac…
题目来源:https://nanti.jisuanke.com/t/A1956 题意:找一个数拆成无平方因子的组合数,然后求前缀和. 解题思路:我们可以把某个数分解质因数,如果某个数可以分解出三个相同的质数那么该f(n)=0,比如8=2*2*2,  24=2*2*2*3,所以f(8)=f(24)=0:如果该数是素数那么f(n)=2:并且我们可以发现,如果m,n互质,那么f(n*m)=f(n)*f(m): #include<iostream> #include<cstring> #i…
题意:\(f(i):i\)能拆分成两个数的乘积,且要求这两个数中各自都没有出现超过1次的质因子.每次给出n,求\(\sum_{i=1}^{n}f(i)\) 分析:\(1 \le n \le 2e7\),每次查询若都\(O(n)\)统计,肯定超时,必须打表. 类似打欧拉函数表的方式,对于数\(d\)以及素数\(p\),\(f(p)=2\): 当\(d|p\)时,若\(d|p^2\),则\(f(d*p^2)=0\):否则\(f(d*p)=f(d)/2\); 当\(d\dagger p\)时,\(f(…
题目大意:就是找一个数拆成两个无平方因子的组合数,然后求个前缀和  ; 分析:运用筛法的思想 ,  因为有序对是由两个合法的数字组成的,所以只要保证第一个数合法,第二个数也合法就行,找出合法的第二个数字的个数就可以用sum前缀和来算,所以L就是第一个数,R=n/L就是最大的第二个数,这里又规定了第二个数从L+1开始,所以sum[R]-sum[L]就是L+1~R合法数字的个数 sum[i] 表示的是小于等于i 的合法因子数 , sum[R]-sum[L] , 就是表示因子大于L,小于等于R,的个数…
题目链接:https://nanti.jisuanke.com/t/31001 题目大意:给出一个含有n个点m条边的带权有向图,求1号顶点到n号顶点的最短路,可以使<=k条任意边的权值变为0. 样例输入 复制 1 5 6 1 1 2 2 1 3 4 2 4 3 3 4 1 3 5 6 4 5 2 样例输出 复制 3 解题思路:可以用两种做法,不过都差不多,应该算是同一种思路的不同写法.第一种是在建图时,将一个点拆成k个层次的点,应该总共有k+1层,每个相同层次的点按输入的边权连接,每个点可以向它…
题目链接: https://nanti.jisuanke.com/t/31001 超时代码: #include<bits/stdc++.h> using namespace std; # define maxn 10000000+10 # define inf 0x3f3f3f3f int n,m,k; int num; int head[maxn]; int dis[maxn]; int vis[maxn]; struct node { int ne; int to; int co; } q…
轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K   Alice, a student of grade 66, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. T…
题目链接:https://nanti.jisuanke.com/t/30991 Feeling hungry, a cute hamster decides to order some take-away food (like fried chicken for only 3030 Yuan). However, his owner CXY thinks that take-away food is unhealthy and expensive. So she demands her hams…
G. Lpl and Energy-saving Lamps 42.07% 1000ms 65536K   During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon imprisoned Lpl in the Castle? Dragon smiled enigmatically and answered that it is a big secre…
题目链接:https://nanti.jisuanke.com/t/30991 2000ms 262144K   Feeling hungry, a cute hamster decides to order some take-away food (like fried chicken for only 3030 Yuan). However, his owner CXY thinks that take-away food is unhealthy and expensive. So she…
262144K   There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl that lives in City 11, she can choose no more than KK roads and make their distanc…
ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the h…
ACM-ICPC 2018 南京赛区网络预赛 A. An Olympian Math Problem 计算\(\sum_{i=1}^{n-1}i\cdot i!(MOD\ n)\) \(\sum_{i=1}^{n-1}i\cdot i! = \sum_{i=1}^{n-1}[(i+1)!-i!](MOD\ n)=n!-1!(MOD\ n)=n-1\) #include<bits/stdc++.h> using namespace std; int T; long long n; int mai…
A. An Olympian Math Problem 54.28% 1000ms 65536K   Alice, a student of grade 66, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him…
J. Ka Chang Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero point. Then, you need to handle QQ operations. There're two types: 1\ L\ X1 L X: Increase points by XX of all nodes whose depth equals LL ( the depth o…
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different schemes there are if you want to use thes…
God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous. Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 33 …
There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N)(1...N), and each time a child is invited,…
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to esca…
Bob is a sorcerer. He lives in a cuboid room which has a length of AA, a width of BB and a height of CC, so we represent it as AA * BB * CC. One day, he finds that his room is filled with unknown dark energy. Bob wants to neutralize all the dark ener…
Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring wonderful substring when the times it appears in that string is between AA and BB (A \le times \le BA≤times≤B). Can you calculate the number of wonderful…
A  签到题 Alice, a student of grade 666, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him. The problem is: We denote k!k!k!: k!=1×2×…
题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems. However, he can submit ii-th problem if and only if he has submitted (and passed, of c…