2018焦作网络赛Give Candies】的更多相关文章

一开始忽略了欧拉定理指数部分是modphi(n-1)没有memset,减法后面没加0:…
题目链接 题意 : 给出 N 个糖果.老师按顺序给 1~N 编号的学生分配糖果.每个学生要么不分.要么最少分一个.且由于是按顺序发放.那么对于某个有分到糖果的编号为 i 的学生.则 1~(i-1) 这些学生都最少有一个糖果.老师必须分完 N 个糖果.问你最后不同的分配方式有多少种 分析 : 队友根据组合计数的方法推出了答案是 2^(N-1) 你也可以通过打表的方式来找到这个规律 但是这里 N 很大.不能直接进行快速幂运算 需要进行降幂处理 有一个男人.他叫欧拉 提出了一个降幂公式 a^n mod…
题目顺序:A F G H I K L 做题链接 A. Magic Mirror 题意:判断 给出的 字符串 是否等于"jessie",需要判断大小写 题解:1.用stl库 tolower ... 2.用ascii码将大写转换为小写,例如: 'A' + 32 = 'a' *F. Modular Production Line 题解:网络流最长区间K覆盖问题, 洛谷P3358 参考题解 参考代码 G. Give Candies 题意:n个小朋友,n个糖,每个小朋友按顺序拿随机数量个糖,直到…
题意:开始有个数k,有个数组和几个运算符.遍历数组的过程中花费一个运算符和数组当前元素运算.运算符必须按顺序花费,并且最后要花费完.问得到最大结果. 用maxv[x][y]记录到第x个元素,用完了第y个运算符时的最大值,minv[x][y]为最小.那么maxv[x][y]要么第y个运算符在x-1之前就用过了,即max[x-1][y],要么x-1之前用到了y-1,再在x的位置用运算符y;因此就是两者取大.还有如果当前遇到的是负数,那么要用最小的来乘,实际上是3者取大. //#pragma comm…
本题算是签到题,但由于赛中花费了过多的时间去滴吧格,造成了不必要的浪费以及智商掉线,所以有必要记录一下坑点 题意:方格从1到n,每一格mjl可以选择吃鱼/巧克力/鸡腿,求走到n格时满足 1.每三格不可重复同一种食物 2.每三格均不同食物时中间格子不可吃巧克力 3.每三格前后两格不可同时吃巧克力 以上三个条件的方案数,n<1e10 太长不看版:打表+快速幂AC 长篇吐槽版 很显然的,设\(dp[n][i][j][k]\),走到第\(n\)格时第\(n-2\)格的食物是\(i\),第\(n-1\)的…
题目链接 题意 : 给出若干个物品的数量和单个的重量.问你能不能刚好组成总重 S 分析 : 由于物品过多.想到二进制优化 其实这篇博客就是存个二进制优化的写法 关于二进制优化的详情.百度一下有更多资料 #include<bits/stdc++.h> #define LL long long #define ULL unsigned long long #define scl(i) scanf("%lld", &i) #define scll(i, j) scanf(…
题目链接 题意 : 实际上可以转化一下题意 要求求出用三个不同元素的字符集例如 { 'A' .'B' .'C' } 构造出长度为 n 且不包含 AAA.BBB CCC.ACB BCA.CAC CBC 这其中任意一个字符串的方案数 分析 : 方法一 (BM 求线性递推) 直接暴力出前 10 项的答案.然后猜它其实可以由线性递推递推而来 丢进杜教的 BM 模板里面就可以直接求出第 N 项了 实际上这个可以不用猜.这种不包含某些串的题目 如果你做过类似的.就会知道实际上是可以构造出一个矩阵然后快速幂…
题目描述 You ye Jiu yuan is the daughter of the Great GOD Emancipator.  And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, she found a small pub called Whitehouse. Just…
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物品,问最终赚的钱的最大值. solution 用两个堆来维护,一个堆维护已经找到卖家的,一个堆维护还没找到卖家的. 对于第\(i\)个地点,在已经找到卖家的堆里找出卖的钱的最小值,如果最小值小于\(a_i\),则将卖家换成\(i\),然后将原来的卖家放到没找到卖家的那里:如果最小值对于\(a_i\)…
题意:四个操作,区间加,区间每个数乘,区间的数变成 2^64-1-x,求区间和. 题解:2^64-1-x=(2^64-1)-x 因为模数为2^64,-x%2^64=-1*x%2^64 由负数取模的性质可知 也就 =(2^64-1)*x%2^64 所以 2^64-1-x=2^64-1+(2^64-1)*x 所以第三个操作也就变成了区间乘 和区间加.  然后就是树剖加线段树多重标记.表示这是第一次写多重标记,整体凭感觉,细节看题解,树剖有点点遗忘,不过还好.今天看群里说邀请赛没什么价值,,细想一下那…
Participate in E-sports 11.44% 1000ms 65536K   Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there…
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different schemes there are if you want to use thes…
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to esca…
You ye Jiu yuan is the daughter of the Great GOD Emancipator. And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, she found a small pub called Whitehouse. Just as she…
God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous. Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 33 …
Mathematical Curse 22.25% 1000ms 65536K   A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthoo…
Transport Ship 25.78% 1000ms 65536K   There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different sch…
// 2019.10.7 练习赛 // 赛题来源:2018 ICPC 焦作区域赛 // CF链接:http://codeforces.com/gym/102028 A Xu Xiake in Henan Province 题目大意 有四个旅游地,给出 n 个人去四个地方的旅游次数,根据他去过旅游地个数输出相应等级. 思路 签到题...(队友在干嘛呀,10min过去了600人交题了啊我们怎么还没AC AC代码 #include<iostream> #include<cstdio> u…
题目链接 题意 : 给出一个由数字组成的字符串.然后要你找出其所有本质不同的回文子串.然后将这些回文子串转化为整数后相加.问你最后的结果是多少.答案模 1e9+7 分析 : 应该可以算是回文树挺裸的题目吧 可惜网络赛的时候不会啊.看着马拉车想半天.卒... 对于每一个节点.记录其转化为整数之后的值 然后在回文串插入字符的时候 不断维护这个信息就行了 其实很好理解.看一下代码就懂了 ( 如果你学过回文树的话... ) 就是多加了变量 val .维护语句 #include<bits/stdc++.h…
There are N children in kindergarten. Miss Li bought them N candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N), and each time a child is invited, Miss Li r…
Problem A Problem B 简单题,做下背包就好了. Problem C Problem D Problem E Problem F Problem G Problem H Problem I 签到. Problem J 也就是判断n和$n(n - 1) / 2$是否为完全平方数. 这个用Java判就可以了(转字符串之后再用牛顿迭代法) Problem K 二进制拆分背包就可以了. Problem L…
There are N different kinds of transport ships on the port. The ith kind of ship can carry the weight of V[i]V[i] and the number of the ith kind of ship is 2c[i]-12^{C[i]} - 12. How many different schemes there are if you want to use these ships to t…
1002 Congruence equation 题目链接  : http://acm.hdu.edu.cn/showproblem.php?pid=6439 题解 : https://www.zybuluo.com/yang12138/note/1262592 相关定理 : 裴蜀定理 在数论中,裴蜀定理是一个关于最大公约数(或最大公约式)的定理.裴蜀定理得名于法国数学家艾蒂安·裴蜀,说明了对任何整数a.b和它们的最大公约数d,关于未知数x和y的线性丢番图方程(称为裴蜀等式): ax + by…
题目描述: Neko has a loop of size n.The loop has a happy value ai on the i−th(0≤i≤n−1) grid. Neko likes to jump on the loop.She can start at anywhere. If she stands at i−th grid, she will get ai happy value, and she can spend one unit energy to go to ((i…
The Power Cube is used as a stash of Exotic Power. There are n cities numbered 1,2,…,n where allowed to trade it. The trading price of the Power Cube in the i-th city is ai dollars per cube. Noswal is a foxy businessman and wants to quietly make a fo…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 思路:很容易推得dp转移公式:dp[i][j] = max(dp[i][j-1],dp[i-1][j],dp[i-1][j-1]+val[i][j]) ,但是很明显离散化后也无法储存这些点,我们可以用树状数组对这个状态转移公式进行优化,我们先以y轴为第一优先级从小到大排序,以x轴为第二优先级从大到小排序,对x轴坐标进行离散化,这样我们就只需要维护x轴上的最大值即可,状态转移方程可优化为: dp[i…
题意:给出\(a[1...n]\),共\(n\)次操作,每次删除一个位置\(p_i\)(强制在线),此时区间会变为两个分离的区间,求每次操作的最大区间逆序对 首先要知道必要的工具,按权值建立的主席树可以在\(O(nlogn)\)内得到任意区间长为\(n\)的逆序对 但每次切除的点如果是不断沿着边来切,那么要统计的区间总长是\(O(n^2)\) 考虑逆序对的贡献是可以互为计算得到的,那么能否每次只对相对较小的区间的复杂度进行统计,得到\(O(nlogn)\)的区间统计总长? 如果已知一个区间\([…
题意:给你一棵树,n个点q次操作,操作1查询x子树深度为d的节点权值和,操作2查询子树x权值和 把每个点按(dfn,depth)的二维关系构造kd树,剩下的只需维护lazy标记即可 #include<bits/stdc++.h> #define rep(i,j,k) for(register int i=j;i<=k;i++) #define rrep(i,j,k) for(register int i=j;i>=k;i--) #define erep(i,u) for(regis…
题意:n个左下角为原点右上角在第一象限的矩形不断覆盖,求最后形成的图形的周长 x和y是独立的,分别维护两棵线段树,一棵表示x坐标下最大的y值,另一棵表示y坐标下最大的x值 从覆盖的角度来考虑,如果逆序处理,当前处理的段的贡献为大于等于当前位置的最大值的差 比如一条横的线段i,坐标为[x1=0,x2],y 那它对答案的贡献为max(0,x2 - max_x of [y,maxy]),此时的区间存在的线段为逆序第n条到第i+1条 处理完后再插入到对应的线段树中即可(其实贡献为0的不插也行,因为都是不…
题意:求本质不同的回文串(大整数)的数字和 由回文树的性质可知贡献只在首次进入某个新节点时产生 那么只需由pos和len算出距离把左边右边删掉再算好base重复\(O(n)\)次即可 位移那段写的略微凌乱.. #include<bits/stdc++.h> #define rep(i,j,k) for(int i=j;i<=k;i++) #define rrep(i,j,k) for(int i=j;i>=k;i--) #define println(a) printf("…