A Boring Problem UVALive - 7676】的更多相关文章

题目链接: I - A Boring Problem UVALive - 7676 题目大意:就是求给定的式子. 学习的网址:https://blog.csdn.net/weixin_37517391/article/details/83821752 思路:证明过程在上面的博客中说了,大体意思就是预处理出两个前缀和,然后通过二项式定理化简式子就好了. AC代码: #include<bits/stdc++.h> using namespace std; # define ll long long…
16年北京现场赛的题,全场过的队30+. 初看只知道 O(N^2logK)的暴力,以为是什么变换. 仔细发现活用 二项式定理 就行. #include <bits/stdc++.h> using namespace std; #define fst first #define scd second #define pb(x) push_back((x)) #define mkp(x,y) make_pair((x),(y)) #define ist(x) insert((x)) typedef…
hihoCoder #1430 : A Boring Problem(一琐繁题) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 As a student of the school of electronics engineering and computer science in Peking University, Kyle took the course named Advanced Algebra in his freshma…
题目大意 给你一棵\(n\)个点的树,每个点有一个颜色\(c_i\),每次给你\(x,y,k\),求从\(x\)到\(y\)的路径上出现次数第\(k\)多的颜色的出现次数 \(n,q\leq 100000\) 题解 树上莫队 先求出这棵树的dfs序(括号序列),记录每个点第一次出现的位置\(st_x\)和最后一次出现的位置\(ed_x\) 若每次询问的\(x,y\)中有一个是另一个的祖先(设\(x\)是\(y\)的祖先),那么就可以视为询问区间\([st_x,st_y]\) 可是一些不在这条链上…
题意:给定n, k,求出∑ni=1(k mod i) 思路:由于n和k都很大,直接暴力是行不通的,然后在纸上画了一些情况,就发现其实对于k/i相同的那些项是形成等差数列的,于是就可以把整个序列进行拆分成[k,k/2],[k/2, k/3], [k/3,k/4]...k[k/a, k/b]这样的等差数列,利用大步小步算法思想,这里a枚举到sqrt(k)就可以了,这样就还剩下[1,k/a]的序列需要去枚举,总时间复杂度为O(sqrt(k)),然后注意对于n大于k的情况,n超过k的部分全是等于k,为(…
转载自https://blog.csdn.net/weixin_37517391/article/details/83821752 题解 其实这题不难,只要想到了前缀和差分就基本OK了. 我们要求的是第$i$项的式子: $F(i)=(a_1+a_2+...+a_i)^k+(a_2+...+a_i)^k+...+a_i^k$ 记$S_i = a_1 + a_2 +...+a_i,S_0=0$ $F(i) = (S_i-S_0)^k+(S_i-S_1)^k+...+(S_i-S_{i-1})^k$…
Problem   UVALive - 3713 - Astronauts Time Limit: 3000 mSec Problem Description Input The input contains several blocks of test cases. Each case begins with a line containing two integers 1 ≤ n ≤ 100000 and 1 ≤ m ≤ 100000. The number n is the number…
Problem   UVALive - 3211 - Now or later Time Limit: 9000 mSec Problem Description Input Output Sample Input 10 44 156 153 182 48 109 160 201 55 186 54 207 55 165 17 58 132 160 87 197 Sample Output 10 题解:2-SAT问题板子题,这个问题主要是理论难度比较大,有了结论之后代码很容易,有专门的论文阐释算…
Problem   UVALive - 4287 - Proving Equivalences Time Limit: 3000 mSec Problem Description Input Output Sample Input 2 4 0 3 2 1 2 1 3 Sample Output 4 2 题解:题意就是给出一个有向图,问最少添加几条有向边能够使得整张图强连通,Tarjan缩点是比较容易想到的,之后怎么办,要用到一个结论:如果图中有a个入度为零的点,b个出度为零的点,那么max(a,…
Problem   UVALive - 5135 - Mining Your Own Business Time Limit: 5000 mSec Problem Description John Digger is the owner of a large illudium phosdex mine. The mine is made up of a series of tunnels that meet at various large junctions. Unlike some owne…
Problem  UVALive - 3523 - Knights of the Round Table Time Limit: 4500 mSec Problem Description Input The input contains several blocks of test cases. Each case begins with a line containing two integers 1 ≤ n ≤ 1000 and 1 ≤ m ≤ 1000000. The number n…
  题目链接:http://acm.swust.edu.cn/problem/1026/     Time limit(ms): 3000 Memory limit(kb): 65535   hzf is crazy about reading math recently,and he is thinking about a boring problem. Now there are n integers Arranged in a line.For each integer,he wants…
A. Palindromes 留坑. B. Modules 将$a$排序,那么最优解中$a_n$一定放在前后一个,且前面$n-1$个每次要么放最小的,要么放最大的,区间DP即可. #include<cstdio> #include<algorithm> #include<bitset> #include<cmath> using namespace std; const int N=505,M=1000; int n,i,j,k,a[N],ans; bits…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…
MASTERING CREATIVITY, 1st EditionThis guide is free and you are welcome to share it withothers.From James Clear:For most of my life, I didn't consider myself to be particularly creative. I didn't play a musicalinstrument (or even know how to read mus…
A. Harmonic Matrix Counter (3/19) B. Binary Tree (1/14) C. Asa's Chess Problem (21/65) [ Problem ] 给出一个棋盘格,里面的格子两两分为一组,组内的格子可以交换位置, 同一组格子一定在同一行或者同一列,每个格子为白色或者黑色, 现在要求每行中黑色的格子数量在rL到rR之间,每列中黑色的格子数量在cL到cR之间, 现在要求求出最少的交换次数使得要求被满足,不能满足则输出-1 [ Solution ] 我…
POJ 3518 Boring Problem : 给一个串S,询问串S有多个子串出现至少两次且位置不重叠. Solution : 对S串建立后缀自动机,再建立后缀树,dfs一遍统计处每个结点的子树中最长节点max和最短节点min.枚举一遍后缀自动机的节点,那么对于其对应后缀的长度要求为小于等于max - min. #include <iostream> #include <algorithm> using namespace std; const int N = 1000008;…
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil Deposit…
专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil DepositsHDU 1495 非常可乐HDU 26…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5922 题意: 给出 $N$ 个冰淇淋球,第 $i$ 个冰淇淋球大小为 $B_i$,现在已知冰淇淋球堆叠起来可组成一个冰淇淋. 对于上下相邻的两个冰淇淋球,只有上面的那个大小不…
后缀数组+RMQ+二分 后缀数组二分确定第K不同子串的位置 , 二分LCP确定可选的区间范围 , RMQ求范围内最小的sa Boring String Problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 661    Accepted Submission(s): 183 Problem Description In thi…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5008 Description In this problem, you are given a string s and q queries. For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is…
Discrete Logarithm Problem 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/D Description http://7xjob4.com1.z0.glb.clouddn.com/42600d1bedc3c308a68ea0453befd84e Input The first line of the input file contains a prime p, 1 < p < 2^13 . This…
Problem Description In this problem, you are given a string s and q queries. For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is the k-th smallest.  A substring si...j of the str…
题目链接:https://vjudge.net/problem/UVALive-5107 题目大意:用ABCDE代表不同的数字,给出形如ABBDE___ABCCC = BDBDE的东西: 空格里面可以填入+-*/的运算符,给字母赋予不同的值,问有多少种情况使得 等式成立. 题目分析: 可以直接用大模拟+暴力求解,注意对于重复情况的判重. 给出代码: #include <iostream> #include <set> #include <algorithm> #incl…
https://vjudge.net/problem/UVALive-7041 题意 给出两个仅包含小写字符的字符串 A 和 B : 求:对于 A 中的每个回文子串,B 中和该子串相同的子串个数的总和. 分析 从0和1两个根节点DFS下去,如果两个相同的节点同时存在就统计答案. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <st…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5919 题意: 给出正整数 $N(1 \le N \le 10^5)$,询问对于正整数 $k$,有多少个小于 $2^N$ 的 $2^k-1$ 是 $7$ 的整数倍. 题解: $…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5921 题意: 一个长度为 $N$ 的序列,要求选出两段不重叠的区间,要求两个区间包含的元素均互不相同,求两段区间的长度和最大为多少. 题解: (主要参考https://blo…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5923 题意: 现有 $N$ 支队伍参加比赛,只有一个队伍能获胜.给出每个队伍一个赔率 $A_i:B_i$,你往这个队投 $x$ 元,若该队获胜你可得到 $\frac{A_i+…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5926 题意: 给出 $N$ 行 $M$ 列的网格,每个格子内可以填入 $[1,K]$ 内的任意整数. 如果某个格子,它是它所在行上严格最大的,同时也是所在列上严格最大的,则认…