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…
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…
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}i th box, each can…
https://nanti.jisuanke.com/t/31719 题意 让你分别判断n或(n-1)*n/2是否是完全平方数 分析 二分高精度开根裸题呀.经典题:bzoj1213 用java套个板子求出平方根,再乘回来检验一下就好. import java.util.*; import java.math.*; public class Main{ static BigInteger check(BigInteger n,BigInteger x) { BigInteger ans=BigIn…
题目链接: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是正方形数.有些整数可以分解为两个无方形整数的乘积,可能有多种分解方…
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 3 c…
这场打得还是比较爽的,但是队友差一点就再过一题,还是难受啊. 每天都有新的难过 A. Magic Mirror Jessie has a magic mirror. Every morning she will ask the mirror: 'Mirror mirror tell me, who is the most beautiful girl in the world?' If the mirror says her name, she will praise the mirror: '…
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…
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…
There are N children in kindergarten. Miss Li bought them NNN 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), and each time a child is invited, Miss Li…
ACM-ICPC 2018 焦作赛区网络预赛 Give Candies n个糖果分给n个小朋友 从1到n个小朋友依次给,每次随机给个数,至少一个,知道没有糖果为止. 问糖果的分布情况方案数. 输出方案数mod 109+710^9+7109+7 考虑只有前i个小朋友得到糖的情况,于是等价于将n个糖果分为i堆,插板法易得方案数是(n−1i−1)\binom{n-1}{i-1}(i−1n−1​) 总方案数∑i=1n(n−1i−1)=2n−1\sum_{i=1}^{n}\binom{n-1}{i-1}=…
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…
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…
https://nanti.jisuanke.com/t/31462 题意 一个N*M的矩形,每个格点到其邻近点的边有其权值,需要构建出一个迷宫,使得构建迷宫的边权之和最小,之后Q次查询,每次给出两点坐标,给出两点之间的最短路径 分析 可以把每个格点视作视作图的点,隔开两点的边视作图的边,则构建迷宫可以视作求其生成树,剩余的边就是组成迷宫的墙.因为要花费最小,所以使删去的墙权置最大即可,呢么就是求最大生成树即可.然后每次查询相当于查这个最大生成树上任意两点的最短距离,到这一步就是个LCA了. 这…
https://nanti.jisuanke.com/t/31721 题意 有肉,鱼,巧克力三种食物,有几种禁忌,对于连续的三个食物:1.这三个食物不能都相同:2.若三种食物都有的情况,巧克力不能在中间:3.如果两边是巧克力,中间不能是肉或鱼.求方案数. 分析 将meat ,  chocolate,fish 用 0 ,1 , 2 表示. 对于 n 来说,我们只关注后两位,因为 若 n - 1 的所有方案解决的话,我们在 n - 1 的方案添加0, 1,2 就行,然后根据禁忌 去除不可能的方案.…
https://nanti.jisuanke.com/t/31711 题意 m个符号必须按顺序全用,n个房间需顺序选择,有个初始值,问最后得到的值最大是多少. 分析 如果要求出最大解,维护最大值是不能得到的,因为有负数的参与,所以我们维护最大值和最小值.不管那么多,反正答案肯定是由极值产生的. 定义dp1[i][j]为用了i个符号,走了j间房后的最大值.因而dp2[][]就是对应的最小值.然后按要求转移. #include<bits/stdc++.h> using namespace std;…
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…
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/31462 要求在一个矩形中任意选两个点都有唯一的通路,所以不会建多余的墙. 要求满足上述情况下,建墙的费用最小.理解题意后容易想到首先假设全部墙都建起来,然后拆掉费用最大的边使图成为一棵树,就是求一颗最大生成树 求出最大生成树后,求任意两点的距离,直接用lca就可以 思路 #include<bits/stdc++.h> #define M 300005 #define pb push_back using namespace std;…
大概就是要每两个点 只能有一条路径,并且约束,最短的边用来砌墙,那么反之的意思就是最大的边用来穿过 故最大生成树 生成以后 再用lca计算树上两点间的距离 (当然防止生成树是一条链,可以用树的重心作为根) ,然后简单的统计下树上两点的距离就行了 #include <bits/stdc++.h> using namespace std; **; int n, m, sum, fa[N]; struct node { int u,v,val; node(){} node(int uu,int vv…
A. Magic Mirror 水. #include <bits/stdc++.h> using namespace std; int t; ]; inline bool work() { int len = strlen(s); ) return false; ] != ] != 'J') return false; ] != ] != 'E') return false; ] != ] != 'S') return false; ] != ] != 'S') return false;…
题意:\(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(…
https://nanti.jisuanke.com/t/31721 题意 n个位置 有几个限制相邻的三个怎么怎么样,直接从3开始 矩阵快速幂进行递推就可以了 #include <bits/stdc++.h> using namespace std; typedef long long ll; ,maxn=; struct Matrix { ll m[maxn][maxn]; Matrix() { memset(m,,sizeof(m)); } void init() { ; i<max…