Let's consider some math problems. JSZKC has a set A=A={1,2,...,N}. He defines a subset of A as 'Meo set' if there doesn't exist two integers in this subset with difference one. For example, When A={1,2,3},{1},{2},{3},{1,3} are 'Meo set'. For each 'M…
题目来源 The 2018 ACM-ICPC China JiangSu Provincial Programming Contest 35.4% 1000ms 65536K Persona5 Persona5 is a famous video game. In the game, you are going to build relationship with your friends. You have N friends and each friends have his upper b…
JSZKC is going to spend his vacation! His vacation has N days. Each day, he can choose a T-shirt to wear. Obviously, he doesn't want to wear a singer color T-shirt since others will consider he has worn one T-shirt all the time. To avoid this problem…
A Plague Inc Plague Inc. is a famous game, which player develop virus to ruin the world. JSZKC wants to model this game. Let's consider the world has N×Mimes MN×M cities. The world has N rows and M columns. The city in the X row and the Y column has…
We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Given a 0689-string $s$ of length $n$, one must do the following operation exactly once: select a non-empty substring of $s$ and rotate it 180 degrees. Mo…
BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the $j$-th column of the $i$-th row (indicated by $(i, j)$) contains an arrow (pointing either upwards, downwards, leftwards or rightwards) and an intege…
A:Martadella Stikes Again 水. #include <bits/stdc++.h> using namespace std; #define ll long long int t; ll R, r; int main() { scanf("%d", &t); while (t--) { scanf("%lld%lld", &R, &r); if (R * R > 2ll * r * r) puts(&…
Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered 11 to nn ,the ii-th pile of stones has a_iai​ stones. There are n - 1n−1 bidirectional roads in total. For any two piles, there is a unique path from…
Travel There are nn planets in the MOT galaxy, and each planet has a unique number from 1 \sim n1∼n. Each planet is connected to other planets through some transmission channels. There are mm transmission channels in the galaxy. Each transmission cha…
Swap There is a sequence of numbers of length nn, and each number in the sequence is different. There are two operations: Swap the first half and the last half of the sequence (if nn is odd, the middle number does not change) Swap all the numbers in…
Angel's Journey “Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on the stage show of the cultural festival, and she is going to look for her human friend, Hinata. So she must find the shortest path to Hinata’s house.…
Tasks It's too late now, but you still have too much work to do. There are nn tasks on your list. The ii-th task costs you t_iti​seconds. You want to go to bed TT seconds later. During the TT seconds, you can choose some tasks to do in order to finis…
链接:https://nanti.jisuanke.com/t/39277 思路: 一开始看着很像树分治,就用树分治写了下,发现因为异或操作的特殊性,我们是可以优化树分治中的容斥操作的,不合理的情况只有当两点在一条链上才存在,那么直接一遍dfs从根节点向下跑途中维护一下前缀和,把所有情况中不合理情况造成的值修正. 这样的话时间复杂度就可以降得非常低了,感觉还可以优化,但是懒得写了 代码耗时:142ms. 实现代码: #include<bits/stdc++.h> using namespace…
题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; long double x[N],y[N]; long double check(long double s){ long double res=0; long double tmp; for(int i=1;i<=n;++i){ tmp=sqrt((s-x[i])*(s-x[i])+(y[i]*y[i…
目录 ACM ICPC China final G Pandaria ACM ICPC China final G Pandaria 题意:给一张\(n\)个点\(m\)条边的无向图,\(c[i]\)代表点\(i\)的颜色,每条边有一个权值 现在有q个询问如下 u w代表从点u出发,每次只能走权值不超过w的边,经过的颜色中次数最多的是哪种颜色,若有多种,输出编号最小的. $ 1<=n<=1e5$ $ 1<=m,q<=2e5$ $ 1<=c_i<=n$ $ 1<=w…
Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了一波食堂,感觉南航食堂装修非常有情调,饭菜种类也很多,打菜的小哥很热情,看到我们用的是20元的饭票但没凑够20块,还送了饮料. 下午热身赛前没事干,给jsb传授了一些玩植物大战僵尸2的经验.热身赛的体验并不很好,机器很卡,没有我们平时习惯用的gedit,写代码的时候保存一下就会卡一会儿,一开始PC2…
题解:最大流板题:增加两个源点,一个汇点.第一个源点到第二个源点连边,权为K,然后第一个源点再连其他点(英雄点)边权各为1,然后英雄和怪物之间按照所给连边(边权为1). 每个怪物连终点,边权为1: 参考代码: #include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f ; int n,m,k,s,t,u,v,w,num,num1; struct Edge { int from, to, cap, flow; }; ve…
目录 Contest Info Solutions A. Maximum Element In A Stack B. Rolling The Polygon C. Caesar Cipherq D. Take Your Seat E. 2-3-4 Tree F. Moving On G. Factories H. Fight Against Monsters J. Nested Triangles K. Vertex Covers L. Continuous Intervals Contest…
G: 要你去才Paul的年龄,Paul的年龄在1~n之间,你每猜一个Paul会告诉你,你猜的这个数和他年龄的gcd,问在最坏情况下最少要猜多少次. 题解: 什么是最坏情况,我们直到如果他的年龄是1的话, 你需要猜一边全部素数.所以很明显这就是最坏情况, 如果p,q是素数,p*q<=n, 我们就可以猜p*q,一次就可以去掉两个素数了. 所以这一题就变成了将1~n的素数分成m部分, 每一部分的乘积要小于等于n. #include <iostream> #include <cstdio&…
E: 模拟题,一开始有n个人(有男有女),对于子女来说线粒体DNA是继承母亲的.然后有m个操作(按时间顺序),一种就是给了父亲,母亲的ID,生了一个孩子(编号从n+1开始往下):还有一个就是 -x , 表示ID为x的人死亡.然后给了你k个信息 ,表示id 为 x 的DNA .问你最后存活的人的DNA是不是一样的. 题解:模拟一下 坑:k个给你的DNA,要标记为祖先的DNA 如果存活的人有一些是有DNA(一种),而一些是不知道的,这种情况是POSSIBLY…
K: 给你n个点以及n-1的条边, 问你最少要加多少条边,使得每两个点割去一条联通的边,还可以使的这两个点连通. 有个一个结论,最少添加的边数为(叶子节点数+1)/ 2. 我们可以只考虑叶子节点数应该怎么连了.按dfs序标号 a0 连 an/2  , a2连an/2+1  ·····.如果是奇数个,就把an连a1. 因为a0可以和别的节点连接,但是怎么样才是最好的,要每一个圈都尽量相交. #include <iostream> #include <cstdio> #include…
B: 现在有一种新的2进制表示法,要你求出0~m-1的每个数的表示. 规则如下:n 是满足 m<=2n 最小数. 而0~m-1的数只能够用n-1个位和n个位来表示. 对于n个位表示的数来说不能有n-1个位表示的数前缀.(如果3表示101那么就不能有10去表示前面的数. 要求要全部数的位数加起来最小, 数从小到大排. 题解:我们先要求出n. 如果是m == 2n 来说.我们不会有n-1位来表示数. 证明:我们有 m/2 个 n-1位数,每一个n-1位数在尾部加上0或者1就可以变成n位的数, 1个n…
A: 给你一个矩阵求'/' 和 '\' 围成的图形,简单签到题,有一些细节要考虑. 题解:一行一行的跑,遇到'/'和'\' 就加0.5, 在面积里面的'.' 就加1.用一个flag来判断是否在围住的图形里面. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <cmath> #…
Then n - 1n−1 lines follow. ii-th line contains two integers f_{a_i}(1 \le f_{a_i} < i)fai​​(1≤fai​​<i), w_i(0 \le w_i \le 10^{18})wi​(0≤wi​≤1018) —The parent of the ii-th node and the edge weight between the ii-th node and f_{a_i} (ifai​​(istart fr…
J. Polygons Intersection time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output We will not waste your time, it is a straightforward problem. Given multiple polygons, calculate the area of their i…
J. Grid Beauty time limit per test 3.0 s memory limit per test 256 MB input standard input output standard output You are given a grid gg consisting of nn rows each of which is divided into mm columns. You can swap any two integers in the same row in…
题目链接 题目大意 一只青蛙在长度为N的字符串上跳跃,"R"可以跳上去,"P"不可以跳上去. 字符串是环形的,N-1和0相连. 青蛙的跳跃距离K的取值范围是[1, N-1],选定K之后不可改变. 要求青蛙最后能跳回起点(起点可以是0-N-1的任意一个位置),问K的取值有多少种选择. \(3≤N≤{10}^5\). 题目思路 主要是要发现每一次走的步数一定是gcd(i,n) 然后发现gcd只有log(n)(可能多一些,但是没多太大) 然后O(n) check 代码 #…
题目链接 题目大意 要你在[l,r]中找到有多少个数满足\(x\equiv f(x)(mod\; m)\) \(f(x)=\sum_{i=1}^{k-1} \sum_{j=i+1}^{k}d(x,i)*d(x,j)\) \(d(x,i)表示x的第i位数\) 题目思路 显然是数位dp,然而这个数位dp不能同时存x%m 和f(x)%m 这样会内存太大存不了,所以存差值即可 还有这个dfs的时候取模只取一次,不然会t,卡常严重 代码 #include<set> #include<map>…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial Collegiate Programming Contest - J Convert QWERTY to Dvorak Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, a poor copy typist, is a user o…
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错误也可以是MLE,而且我的内存就是卡了那么一点点,在比赛紧张的状态下人也变傻了吧. 这次的题目难度是两边到中间一次递增的,但是我也不懂榜怎么会那样  A Peak Time Limit: 1 Second      Memory Limit: 65536 KB A sequence of  inte…