题意:
给出一颗n个结点的有根树,边有长度;
每个点有可以购票前往长度相差不超过li的它的祖先,票的花费为pi*长度+qi;
当然的,可以的选择多次倒车到达;
求每个点到根的最小花费;
n
题解:
这题真的好贴心,数据特殊情况都给你让你特判了2333;
首先一条链的情况都会吧,设f[i]为i到根的最小花费,dis为到根的距离;
转移方程为:f[i]=f[j]+p[i]*(...
分类:
其他好文 时间:
2015-08-31 19:45:24
阅读次数:
192
Tian Ji -- The Horse Racing
Problem Description
Here is a famous story in Chinese history.
"That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to...
分类:
其他好文 时间:
2015-08-27 13:19:45
阅读次数:
146
题目
分析:枚举最大数,然后找出它所有因数p1…….pk, 从中任意选取一些数,这些数的LCM|这个数且,这些数的最大LCM就是枚举的这个数,且若pi<=aj<=pi+1则前i个数可以放在j这个位置,即j这个位置有cj种选择,总方案数就是c1*c2*……*cj
作为优化,对于每个pi,我们枚举有aj满足pi<=aj<=pi+1的个数记为qi,则有ans=1^qi*2^qi*……*q^qk,但这些...
分类:
其他好文 时间:
2015-08-25 23:56:12
阅读次数:
199
田忌赛马
时间限制:3000 ms | 内存限制:65535 KB
难度:3
描述Here is a famous story in Chinese history.
"That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to...
分类:
其他好文 时间:
2015-08-16 19:56:12
阅读次数:
103
Tian Ji -- The Horse Racing
Description
Here is a famousstory in Chinese history.
That was about2300 years ago. General Tian Ji was a high official in the country Qi. He likesto play horse racing ...
分类:
编程语言 时间:
2015-08-15 18:26:06
阅读次数:
165
Catching the Thief
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 653 Accepted Submission(s): 359
Problem Description
In the Qi...
分类:
其他好文 时间:
2015-08-14 17:09:09
阅读次数:
119
输入是一个只包含拼音的字符串,请输出对应的数字序列。转换关系如下:
描述: 拼音 yi er san si wu liu qi ba jiu
阿拉伯数字 1 2 3 4 5 6 7 8 9
输入字符只包含小写字母,所有字符都可以正好匹配
运行时间限制:无限制
内存限制: 无限制
输入: 一行字符串,长度小于1000
输出: 一行字符(数字)串
样例输入: yie...
分类:
其他好文 时间:
2015-08-14 10:02:23
阅读次数:
176
DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes t...
分类:
其他好文 时间:
2015-08-13 11:26:28
阅读次数:
95
DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes t...
分类:
其他好文 时间:
2015-08-11 09:48:31
阅读次数:
127
DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes t...
分类:
其他好文 时间:
2015-08-09 20:33:06
阅读次数:
105