一.题面 样例输入: 5 4 3 10 5 2 7 10 5 1 4 8 7 2 3 6 4 7 样例输出: 4 0 1 1 3 6 5 1 5 1 2 0 3 2 4 4 3 6 5 1 二.思路 关键词:线段树 这道题最难就难在看题吧...也许ACM的魅力之一便在于此——面对若干道题,你不知每一道题的难度是高是低,只能耐心地读清题面,审清题意,理清思路,方可知其是否在能力范围内以及预估耗时.考试过程中,我基本靠board来判断题目难度,清北大佬们先AC了哪些我就先做哪些...然而这道题似乎他…
一.题面 样例输入: 2 5 8 样例输出: 8 14 二.思路 关键词:线性筛 在Zed的帮助下知道了这是一道线性筛的比较裸的题了.考试过程中肝这道题的时间最久,费了心思找到递推式后,发现根本不是在1s内能实现的东西.考试过程中大三学长选择了暴力打表打了几十KB...考后向Zed请教良久知道了线性筛.线性筛最基础的作用是筛出所有质数,时间复杂度仅为o(n).由于f(x)是“积性函数”(f(a * b) = f(a) * f(b)),所以也可以用线性筛处理. 三.代码 #include <cst…
一.题面 样例输入: 15 6 11 2 21 3 42 4 33 4 13 5 64 5 2 样例输出: 3 二.思路 关键词:分层BFS 考试时觉得题干意思很清晰——求可将k条边赋值为0的最短路.起初几个思路正确性均存疑,后来觉得应该要DP于是决定滞后了... 正解——分层BFS,个人认为思路与DP有些许相像,同时记录节点及当前已赋值为0的边数,则在跑最短路时(这里用的SPFA),可选择是否将该条边赋值为0,当且仅当已选边<k. 三.代码 #include <cstdio> #inc…
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…
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 secret. After a pause, Dragon added: — We have a contract.…
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 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…
题目链接: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…
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…