随笔分类 - 经典题
摘要:You are given an array of nn integers a1,a2,...,ana1,a2,...,an. We define that a sequence p1,p2,...,pk(k∈[1,n])p1,p2,...,pk(k∈[1,n]) is beautiful if a
阅读全文
摘要:题目链接: https://cn.vjudge.net/contest/313499#problem/L SOLUTION: 对于题意,要求最短的表达式,当用最小循环元来表示一个字符串时,其表达式才最短。对于字符串S自匹配求出next数组,分析可以发现:当i-next[i]能整除i时,S[1~i-n
阅读全文
摘要:Define S[n] as the number of subsets of {1, 2, ..., n} that contain no consecutive integers. For each S[n], if for all i (1 ≤ i < n) gcd(S[i], S[n]) i
阅读全文
摘要:Your friend has made a computer video game called "Kangaroo Puzzle" and wants you to give it a try for him. As the name of this game indicates, there
阅读全文
摘要:After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a Nogaku show during the feast. To enjoy the show,
阅读全文
摘要:Description JYY 带队参加了若干场ACM/ICPC 比赛,带回了许多土特产,要分给实验室的同学们。 JYY 想知道,把这些特产分给N 个同学,一共有多少种不同的分法?当然,JYY 不希望任 何一个同学因为没有拿到特产而感到失落,所以每个同学都必须至少分得一个特产。 例如,JYY 带来了
阅读全文
摘要:题目描述 树上最大独立集是个非常简单的问题,可怜想让它变得稍微难一点。 可怜最开始有一棵 nn 个点无根树 TT,令 T(i)T(i) 为将点 ii 作为根后得到的有根树。 可怜用 mm 次操作构造了 m+1m+1 棵树 T'_0T0′ 至 T'_mTm′,其中 T'_0 = T(1)T0′=
阅读全文
摘要:G. Snake Rana time limit per test 4.0 s memory limit per test 256 MB input standard input output standard output G. Snake Rana time limit per test 4.0
阅读全文
摘要:题目描述 有一个 nn 个点 n-1n−1 条边的无向连通图迷宫,其中有些点上面有人现在所有人的目标都是逃离这个迷宫,而迷宫的出口是 11 号点,每一时刻,会依次发生以下的事情: 在点 xx 上的人选择一个点 f(x)f(x) 作为目标,要求 f(x)f(x) 必须是 xx,或者与 xx 有边相连的
阅读全文
摘要:E. Getting Deals Done time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output E. Getting Deals D
阅读全文
摘要:题意:给定一棵以1为根的n个节点的树,多个询问,每次询问给出一个集合,集合内的点表示为不重要的点(不在集合内的点就是重要的点),求给定这个集合后有多少点能进入另一个集合,点x进入另一个集合的要求:1:重要的点。2:有两个重要的点的最近公共祖先为x。 分析:其实对于每一个询问我们只要判断哪些不重要的点
阅读全文
摘要:E. Packmentime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA game field is a strip of 1 × n square
阅读全文
摘要:A. Automatic Door time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is an automatic d
阅读全文
摘要:题目描述 加里敦星球的人们特别喜欢喝可乐。因而,他们的敌对星球研发出了一个可乐机器人,并且放在了加里敦星球的1号城市上。这个可乐机器人有三种行为: 停在原地,去下一个相邻的城市,自爆。它每一秒都会随机触发一种行为。现 在给加里敦星球城市图,在第0秒时可乐机器人在1号城市,问经过了t秒,可乐机器人的行
阅读全文
摘要:题目描述 在 x−yx-yx−y 直角坐标平面上有 nnn 条直线 L1,L2,…LnL_1,L_2,…L_nL1,L2,…Ln,若在 yyy 值为正无穷大处往下看,能见到 LiL_iLi 的某个子线段,则称 LiL_iLi 为可见的,否则 LiL_iLi 为被覆盖的。 例如,对于直线:
阅读全文