
日常训练
文章平均质量分 87
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
codeforces161D. Distance in Tree(树形DP)
思路:dp[i][j]表示点 i 的子节点到点 i 的距离为j的路径个数。设一点为u,其子节点为v, u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][j-1];每个点对答案的贡献为:ans+=dp[u][j]*dp[v][(k-1-j)];#include <iostream>#include<cstdio>#include<c...原创 2019-10-08 10:24:40 · 141 阅读 · 0 评论 -
E. Polycarp and Snakes
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size原创 2019-06-24 16:52:25 · 269 阅读 · 0 评论 -
Best Solver HDU - 5451 (共轭构造)
The so-called best problem solver can easily solve this problem, with his/her childhood sweetheart.It is known thaty=(5+26–√)1+2xy=(5+26)1+2x.For a given integerx(0≤x<232)x(0≤x<232)and ...原创 2019-06-25 12:32:44 · 179 阅读 · 0 评论 -
E. Product Oriented Recurrence(矩阵快速幂)
Let原创 2019-06-16 00:20:07 · 297 阅读 · 0 评论 -
C. Beautiful Lyrics (CodeForces)
You are given原创 2019-06-14 20:20:44 · 308 阅读 · 0 评论 -
Minimal Segment Cover(1175E) 倍增
You are given原创 2019-06-14 10:59:07 · 316 阅读 · 0 评论 -
Most Distant Point from the Sea UVA - 1396
#include <iostream>#include <cstdlib>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <vector>#include <queue>#incl...原创 2019-04-30 21:40:27 · 148 阅读 · 0 评论 -
问题 I: Winner Winner
The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Training Center of Fuzhou University. The activity mainly includes the programming contest like ACM-ICPC and strive to provide...原创 2019-05-05 20:05:23 · 415 阅读 · 0 评论 -
问题 M: Little Sub and Johann
思路:直接用SG函数会超时,对SG函数打一下表找规律。可以发现当x为质数时,sg[x]=x是第几个质数+1。当x不为质数时,sg[x]=sg[p]且p是x的最小质因子。#include<iostream>#define ll long long#include <stdio.h>#include <string.h>#define N 10...原创 2019-05-05 16:20:01 · 125 阅读 · 0 评论 -
问题 J: Floating-Point Hazard
题目描述Given the value of low, high you will have to find the value of the following expression:If you try to find the value of the above expression in a straightforward way, the answer may be inc...原创 2019-04-29 19:59:28 · 258 阅读 · 0 评论 -
Flood Fill CodeForces - 1114D
You are given a line ofnncolored squares in a row, numbered from11tonnfrom left to right. Theii-th square initially has the colorcici.Let's say, that two squaresiiandjjbelong to the same...原创 2019-04-19 16:43:30 · 210 阅读 · 0 评论 -
Board Wrapping UVA - 10652
算出这些点的凸包后,计算凸多边形的面积#include <cstdio>#include <cmath>#include <vector>#include <algorithm>#include <cstring>#include <iostream>using namespace std;const d...原创 2019-04-28 19:16:00 · 283 阅读 · 0 评论 -
D. Subarray Sorting(线段树 )codeforces1187
思路:用一个队列aa存一下a数组中每一个数的位置。我们遍历数组b去找aa[b[i]].front(表示数b[i]在a第一个出现的位置),找从1到该位置的最小值是否是b[i],若不是 则为no,若是则将 改位置的数组a的数赋值成inf 以更新该区间最小值。就这样 一直找下去。。#include <iostream>#include <cstring>#inclu...原创 2019-07-03 11:35:18 · 397 阅读 · 2 评论 -
D1. Submarine in the Rybinsk Sea (easy edition)
思路:每个第k位(从1开始)都会恰好在2k和2k−1位各贡献n次#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <cmath>#include<strin...原创 2019-07-18 11:35:07 · 226 阅读 · 0 评论 -
I. Misunderstood … Missing (DP)
Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended ...原创 2019-10-06 15:27:04 · 732 阅读 · 0 评论 -
D.Modulo Nine (DP)
思路:若要a1*a2*a3....*an能mod9等于0,则该算式中必有两个因子3相乘或者含有0。对于一个右端点r,有多个[l,r]的时候,只要最小的那个区间满足,其他肯定都满足了。这样对于一个右端点的限制条件是否满足,取决于前面出现的最后两个3出现的位置(9和0算作两个3)由此我们设dp[i][j][k]表示前i个数,最后一个因子3出现的位置为j,倒数第二个为k。由于因子中含有3的数有3、...原创 2019-10-06 11:28:01 · 294 阅读 · 0 评论 -
2019牛客国庆集训派对day1 -I 2019
思路:dp[i][j]表示点 i 的子节点到点 i 的距离mod 2019 = j的路径个数。设一点为u,其子节点为v,u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][(j-w+2019)%2019];#include <iostream>#include<cstdio>#include<cstring>#include<a...原创 2019-10-05 09:53:27 · 429 阅读 · 0 评论 -
Problem J. Prime Game 2019南京站ICPC
思路:计算第i个数中包含的每个素数对答案的贡献(其贡献的区间为[i,i+1,i+2...n],则贡献为n-i+1)#include<bits/stdc++.h>#define ll long longusing namespace std; int n,a[1000010];vector<int> v[1000010]; int main(){ ...原创 2019-10-04 16:14:34 · 288 阅读 · 0 评论 -
BZOJ1013 (高斯消元模版题)
#include<iostream>#include<cstring>#include<cstdio>#include<cmath>#define ll long longusing namespace std;double a[20][20],b[20],c[20][20];int n;int main(){ cin>...原创 2019-09-02 21:16:04 · 190 阅读 · 0 评论 -
中国剩余定理模版
#include<iostream>#include<cstdio>#define ll long longusing namespace std;//扩展欧几里得算法void gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(b==0){ d=a; x=1; ...原创 2019-08-31 21:05:43 · 120 阅读 · 0 评论 -
扩展中国剩余定理模版
#include <cstdio>using namespace std;typedef long long ll;ll exgcd(ll a,ll b,ll &x,ll &y){ if(!b)return x=1,y=0,a; ll d=exgcd(b,a%b,x,y),z=x; x=y,y=z-a/b*y; return d...原创 2019-08-31 20:59:48 · 154 阅读 · 0 评论 -
2019hdu暑假多校训练赛第七场1006 Final Exam hdu6651(思维)
思路: 作为老师的话。他想让你过不了,那会拿n-k+1道题卡你。 对于学生的话。 若想在n-k+1道题目里面过一道。这n-k+1道题的分值最坏情况就是m。 所以要至少要学m+1小时。 然后对于剩下的k-1道题。 最坏的情况就是老师拿m/(n-k+1)的分数去卡你。 所以若要做对这k-1道,则学习时间是(m/(n-k+1)+1)*(k-1)。#inc...原创 2019-08-13 15:01:27 · 158 阅读 · 0 评论 -
Wave(ccpc江西省赛)
Problem DescriptionAvin is studying series. A series is called "wave" if the following conditions are satisfied:1) It contains at least two elements;2) All elements at odd positions are the same;...原创 2019-07-22 08:18:05 · 250 阅读 · 0 评论 -
牛客暑假多校训练第一场 E ABBA
思路: 设dp[i][j]表示有i个A,j个B的方法数。考虑递推方程: 当i<n+j时可以放A(如果A的个数i小于n或者放的’B‘的个数j小于多出来的’A’ 则可以直接放i)得到递推式: dp[i+1][j]+=dp[i][j]同理 知: j<m+i可以放B 递推式:dp[i][j+1]+=dp[i][j]#in...原创 2019-07-19 13:55:28 · 134 阅读 · 0 评论 -
2019年牛客多校第一场B题 Integration
思路:将进行裂项化简得: 由于则原式等于求解该式即可#include<iostream>#include<cstdio>#define ll long long#define mod 1000000007using namespace std;ll n,a[1008611],num[1008611];long long fast_mod(lon...原创 2019-07-19 12:35:15 · 144 阅读 · 0 评论 -
冰水挑战 HDU - 6495
Polar Bear Pitching helps you crystallize your message.The stage could not be any cooler, and we mean literally:a hole cut through the ice in the frozen Baltic Sea.2050有一项很有挑战的活动 —— Polar Bear P...原创 2019-04-19 11:06:09 · 392 阅读 · 0 评论 -
Dog Distance UVA - 11796
思路:对甲乙,看谁先到达拐点。分析从之前的位置到拐点的位置两者的运动过程,那么这个过程中两者都做的直线运动,而且运动是相对的,则把甲看成静止的,乙做相对运动。更新出在这个过程中的最大值和最小值。并更新甲乙经过此轮运动后所在位置。然后再找谁先到拐点。。。。直到到末位置为止。#include<iostream>#include<cstdio>#include<c...原创 2019-04-22 19:55:19 · 148 阅读 · 0 评论 -
C. Colorful Bricks(dp)
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are原创 2019-04-17 19:55:51 · 366 阅读 · 0 评论 -
T-net(贪心)
T-net which is a new telecommunications company, plans to install its base stations in the city. The places where base stations must be installed have been already specified. T-net has two types of an...原创 2019-04-08 22:03:35 · 3181 阅读 · 2 评论 -
Master of Random
Hakase provides Nano with a problem. There is a rooted tree with values on nodes. For each query,you are asked to calculate the sum of the values in the subtree. However, Nano is a rookie so she decid...原创 2019-04-08 15:22:57 · 242 阅读 · 0 评论 -
Heap Partition ZOJ - 3963
A sequenceS= {s1,s2, ...,sn} is calledheapableif there exists a binary treeTwithnnodes such that every node is labelled with exactly one element from the sequenceS, and for every non-root no...原创 2019-04-01 22:12:19 · 217 阅读 · 0 评论 -
Master of Phi(数论)
You are given an integer n. Please output the answer of modulo 998244353. n is represented in the form of factorization.φ(n) is Euler’s totient function, and it is defi ned more formally as the num...原创 2019-04-07 11:10:19 · 358 阅读 · 0 评论 -
A Magic Lamp HDU - 3183 (ST表)
Kiki likes traveling. One day she finds a magic lamp, unfortunately the genie in the lamp is not so kind. Kiki must answer a question, and then the genie will realize one of her dreams.The question ...原创 2019-04-06 11:26:17 · 182 阅读 · 0 评论 -
Two Cakes(codeforces)1030B
Sasha and Dima want to buy two原创 2019-03-03 15:21:29 · 428 阅读 · 0 评论 -
2019 蓝桥杯省赛 B 组模拟赛(一)
F:找质数一天蒜头君猜想,是不是所有的偶数(除了 22),都可以用两个质数相加得到呢?于是聪明的蒜头君就找你来验证了。输入格式第一行输入一个整数 tt 表示测试组数。接下来 tt 行,每行一个整数 nn。输出格式输出两个整数,因为答案可能有多个,所有要求输出的这两个整数是所有答案中字典序最小的。 这个真鸡肋,居然卡输入输出。#include<iostre...原创 2019-02-16 18:25:55 · 564 阅读 · 0 评论 -
问题 A: 【贪心】删数问题
题目描述输入一个高精度的正整数n(≤240位),去掉其中任意s个数字后,剩下的数字按原左右次序组成一个新的正整数。编程对给定的n和s,寻找一种方案,使得剩下的数字组成的新数最小。输入第1行:一个正整数n;第2行:s(s<n的位数).输出最后剩下的最小数。思路:跟据贪心,只需要从前往后查找并删除s个前一位比后一位大的数(若都符合条件则删除最后一位)。这里熟练运用str...原创 2019-02-16 18:11:05 · 505 阅读 · 0 评论 -
Cube
题目描述给你一个n*m的棋盘,有一个1*1*2的长方体竖直放在(1,1)上,你可以将其在棋盘上滚动,你的目标是让其竖直放在(n*m)上,问至少需要多少次操作。(放倒、竖直、翻滚) 输入一行,两个整数n,m (n<=m) 输出需要最少时间逃脱密室。若无解输出impossible。 思路:由于计算的是最少操作次数,尽量让‘长’着地,那么一次放到+一次立起的长度...原创 2018-12-25 12:40:16 · 279 阅读 · 0 评论 -
抵制克苏恩
小Q同学现在沉迷炉石传说不能自拔。他发现一张名为克苏恩的牌很不公平。如果你不玩炉石传说,不必担心,小Q同学会告诉你所有相关的细节。炉石传说是这样的一个游戏,每个玩家拥有一个 30 点血量的英雄,并且可以用牌召唤至多 7 个随从帮助玩家攻击对手,其中每个随从也拥有自己的血量和攻击力。小Q同学有很多次游戏失败都是因为对手使用了克苏恩这张牌,所以他想找到一些方法来抵御克苏恩。他去求助职业炉石传说玩家椎名...原创 2018-12-24 22:08:11 · 167 阅读 · 0 评论 -
10297: Podzielno
题目描述B进制数,每个数字i(i=0,1,...,B-1)有a[i]个。你要用这些数字组成一个最大的B进制数X(不能有前导零,不需要用完所有数字),使得X是B-1的倍数。q次询问,每次询问X在B进制下的第k位数字是什么(最低位是第0位)。 输入第一行包含两个正整数B(2<=B<=10^6),q(1<=q<=10^5)。第二行包含B个正整数a[0],a[1]...原创 2018-12-19 16:36:43 · 111 阅读 · 0 评论 -
Multiplying Digits(Dp+map)
For every positive integer we may obtain a non-negative integer by multiplying its digits. This defines a functionf, e.g.f(38) = 24.This function gets more interesting if we allow for other bases. ...原创 2019-04-15 21:47:29 · 302 阅读 · 0 评论