摘要: 题意 给一棵有权值的树,每次询问给u,v,x,问u到v的路径上所有点的权值与x的gcd的乘积(对1e9+7取模) 分析 + 离线搞 + 对于每个素数单独处理 + 每确定一个素数之后,从低到高枚举该素数的指数,并把跟这个素数相关的点拿出来更新在树上更新指数的大小。更新完毕之后,可以求得u,v之间指数的 阅读全文
posted @ 2018-06-19 12:23 sciorz 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 标签: 线段树 题目链接 https://codeforces.com/contest/981/problem/E 分析 在线段树的每个节点维护一个 . 代码 cpp include include include include include include include using name 阅读全文
posted @ 2018-06-08 17:51 sciorz 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 牛客练习赛19 托米去购物 标签: 网络流 题目链接 https://www.nowcoder.com/acm/contest/111/D 分析 + 因为总金额有限,所以要求现金使用最小也就意味着优惠券使用最多 + 源点连优惠券,流量为优惠券金额;优惠券连物品,流量为INF;物品连汇点,流量为物品价 阅读全文
posted @ 2018-06-08 14:04 sciorz 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 标签 : 状态压缩dp 题目链接 https://www.nowcoder.com/acm/contest/111/B 分析 + 用dp[i][j]来表示已经有i个人成功就坐,且坐下的状态为j的二进制. + 转移的时候枚举第i个人卡片上的数字 代码 cpp include include inclu 阅读全文
posted @ 2018-06-08 13:50 sciorz 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目链接 https://arc067.contest.atcoder.jp/tasks/arc067_c 题意 把n个人分组,每组的人数必须在A B之间.并且如果有一个组有i(i 0)个人,那么有i个人的组数要在C D之间.问有多少种分组方案 分析 + 用dp[i][j]来表示从n个人中取出i个来 阅读全文
posted @ 2018-06-01 16:19 sciorz 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 题目描述 SR得到了一个n m的矩阵,矩阵行列从1开始标号,每个格子有不同的权值,Steam为了测试SR的智力,决定给他q个操作,每次操作交换两个大小一样的子矩阵,并在操作完之后输出它。 每个操作由6个正整数$A_i,B_i,C_i,D_i,H_i,W_i$组成,分别表示第一个子矩阵的左上角位于哪一 阅读全文
posted @ 2018-05-31 11:34 sciorz 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 标签 : 数学 逆元 题目描述 一个弹球(可视为质点)被水平抛出,落地时发生完全弹性碰撞,设弹球第一次落地位置为x,则第i次落地位置为(2i 1)x.若弹球第一次落地的位置在区间[L,R]均匀随机分布,求弹球落在区间[L,R]内的总次数的数学期望值 可以证明答案为有理数,若答案表示为最简分数为a/b 阅读全文
posted @ 2018-05-26 17:03 sciorz 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 标签: 字符串hash 题目链接 https://codeforces.com/contest/985/problem/F 题意 首先定义两个长度相等字符串a,b同构,当且仅当a中的每个字母,b中只存在一个字母与之对应,并且两个字母出现位置要完全一致,a,b反过来也要满足。 给定一个长度为$2 \t 阅读全文
posted @ 2018-05-26 13:08 sciorz 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 标签 : DP 题目链接 http://codeforces.com/contest/985/problem/E 题意 把$n$个数分成多组,使得每组包含至少$k$个元素,且每组中的任意两个元素之差不超过$d$ 分析 + 很巧妙的DP + 我们使用 来表示(如果不存在i+1~n个元素的时候)前i个能 阅读全文
posted @ 2018-05-26 12:56 sciorz 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 标签(空格分隔): Trie树 题目链接 http://codeforces.com/problemset/problem/979/D 题意 给定一个空集合,有两种操作: 一种是往集合中插入一个元素,一种是给三个数$x,k,s$,问集合中是否存在$v$,使得$x\ mod\ k==0$且$v\ mo 阅读全文
posted @ 2018-05-21 20:14 sciorz 阅读(294) 评论(0) 推荐(0) 编辑
摘要: Problem Statement For integers _b_(_b_≥2) and _n_(_n_≥1), let the function _f_(_b_,_n_) be defined as follows: _f_(_b_,_n_)=_n_, when _n_ _f_(_b_,_n_) 阅读全文
posted @ 2018-05-20 11:01 sciorz 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 标签: 状态压缩DP 题目描述 Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. Iroha is looking 阅读全文
posted @ 2018-05-19 00:52 sciorz 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 标签 : 动态规划 题目描述 Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the bac 阅读全文
posted @ 2018-05-19 00:33 sciorz 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 标签: 可持久化线段树 题目描述 The h index of an author is the largest h where he has at least h papers with citations not less than h . Bobo has published n papers 阅读全文
posted @ 2018-05-19 00:20 sciorz 阅读(652) 评论(2) 推荐(1) 编辑
摘要: 标签: 单调队列 题目描述 有一个a b的整数组成的矩阵,现请你从中找出一个n n的正方形区域,使得该区域所有数中的最大值和最小值的差最小。 输入格式: 第一行为3个整数,分别表示a,b,n的值 第二行至第a+1行每行为b个非负整数,表示矩阵中相应位置上的数。每行相邻两数之间用一空格分隔。 输出格式 阅读全文
posted @ 2018-05-17 13:18 sciorz 阅读(157) 评论(0) 推荐(0) 编辑