AllCrazy
格桑花 · 共 33 篇文章
PKU 2516 Minimum Cost
Minimum Cost Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 8593 Accepted: 2825 Description Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply plac…
2011-07-15 19:35 · Unsolve · 评论(0)
ural 1100 Final Standings
1100. Final Standings Time Limit: 1.0 second Memory Limit: 16 MB Old contest software uses bubble sort for generating final standings. But now, there are too many teams and that software works too slow. You are asked to write a program, which generates exactly the same final standings as old softwa…
2011-07-10 17:11 · Ural · 评论(0)
tyvj 1088 treat
描述 Description 给出长度为N的数列{A_i},每次可以从最左边或者最右边取走一个数,第i次取数得到的价值是i * A_j。求价值之和最大的取数方案。 输入格式 Input Format 第一行,一个整数,表示数列长度N。 接下来N行,每行一个整数,表示数列A_i。 输出格式 Output Format 一个整数,表示最大的价值之和。 算法分析: 设在区间按照题目要求取数所获得的最大值为f(i,j),则 f(i,j) = max{f(i+1,j)+a**(n+i-j),f(i,j-1)+a**(n+i-j)} f(i,i) = a**n 代码: #include <iostrea…
2011-07-10 15:25 · Dynamic Programming · 评论(0)
tyvj 1348 清理内奸
清理内奸 描述 Description 最近FF博士在玩一个游戏“三国杀杀杀”,他扮演一个英明的主公,四处清剿反贼。终于把反贼全部干掉了,可是他的手下还存在着一些内奸 。经过他的观察和研究,终于发现了内奸的重要特征。内奸最重要的工作就是传递情报,所以内奸必须掌握各种加密方法。于是他们对素数有 一种偏好,编号是素数的人全部是内奸。FF博士将指挥忠臣干掉内奸。忠臣和内奸排成一排,第i个人的编号为Bi。杀死内奸会获得一定量经验 ,等级为X的忠臣杀死任意等级的内奸会获得X点经验。每个人都有一定的攻击范围,若站在i位置的人攻击范围为k那么他可以杀范围 内的人,但是每个人都只有一次攻击的机会。内奸们并不…
2011-07-10 10:26 · ACM · 评论(0)
USACO Packing Rectangles
http://www.uwp.edu/sws/usaco/ Packing Rectangles IOI 95 The six basic layouts of four rectangles Four rectangles are given. Find the smallest enclosing (new) rectangle into which these four may be fitted without overlapping. By smallest rectangle, we mean the one with the smallest area. All four re…
2011-06-21 23:11 · Unsolve · 评论(0)
poj3624 Charm Bracelet
Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a 'desirability' factor Di (1 ≤ Di ≤ 100)…
2011-06-19 23:06 · POJ · 评论(0)
1.3 Calf Flac
Calf Flac To make the programming easier, we keep two copies of the text: the original, and one with the punctuation stripped out. We find the biggest palindrome in the latter copy, and then figure out which part of the original it corresponds to. To find the biggest palindrome in the alphabetic te…
2011-06-18 18:08 · USACO · 评论(0)
Barn Repair
Barn Repair 题目大意:有S个牛栏,其中有C头牛在里面,一些牛栏有牛,一些没有,最大有M块的板子,每块板子的长度可以任意长,用这些板子去拦住所有的牛,使它们都被围住。求最小会有多少牛栏会被围住。 算法分析:isin~~:表示第i个牛栏里是否有牛。 v:表示连续的没有牛的牛栏数。 设一共有top块连续的牛栏里有牛。则可以知道:如果top<=M,则结果就是所有住有牛的牛栏数;否则的话,就需要通过中间没有牛的牛栏连接两块有牛的区域连起来,我们知道,每次这样做都会使所需用的木板数减少,但同时会增加牛栏数。此时,我们很容易想到我们只需每次选择最少数量的没有牛的牛栏块,即只需对数组v进行排序,…
2011-06-17 19:32 · USACO · 评论(0)
HDU 2079 选课时间
选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1038 Accepted Submission(s): 872 Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合。你来帮帮他吧。(xhd认为一样学分的课没区别) Input 输入数据的第一行是一个数据T,表示有T组数据。 每组数据的第一行是两个整数n(1 <= n <=…
2011-06-08 23:39 · Combination Mathematics · 评论(0)
Ural 1017. Staircases
1017. Staircases Time Limit: 1.0 second Memory Limit: 16 MB One curious child has a set of N little bricks (5 ≤ N ≤ 500). From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed for staircase to have steps eq…
2011-06-06 19:39 · Dynamic Programming · 评论(0)
Ural 1009. K-based Numbers
K-based Numbers Time Limit: 1.0 second Memory Limit: 16 MB Let’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For example: 1010230 is a valid 7-digit number; 1000198 is not a valid number; 0001235…
2011-06-06 15:34 · Dynamic Programming · 评论(0)
1104. Don’t Ask Woman about Her Age
Don’t Ask Woman about Her Age Time Limit: 1.0 second Memory Limit: 16 MB Mrs Little likes digits most of all. Every year she tries to make the best number of the year. She tries to become more and more intelligent and every year studies a new digit. And the number she makes is written in numeric sy…
2011-06-06 00:09 · Number Theory · 评论(0)
Ural 1091. Tmutarakan Exams
Tmutarakan Exams Time Limit: 1.0 second Memory Limit: 16 MB University of New Tmutarakan trains the first-class specialists in mental arithmetic. To enter the University you should master arithmetic perfectly. One of the entrance exams at the Divisibility Department is the following. Examinees are …
2011-06-05 23:46 · Number Theory · 评论(0)
Ural 1086. Cryptography
Cryptography 题目大意:输入一个数n(n<=15000),要求输出第n 个素数。 题目分析:简单题,考察素数筛选法。 代码: #include <iostream> #include <cstdio> #include <cmath> using namespace std; const int maxn=200010; int prime[maxn]; int pnum; void getPrime() { pnum=0; prime[pnum++]=2; for(int i=3;i<=maxn;i+=2) { bool isprime=true; int cap=sqrt((…
2011-06-05 13:35 · Number Theory · 评论(0)
Ural Brave Balloonists
Ural Brave Balloonists 题目大意:给定10个数ai(1<=ai<=10000),m=a1 a2 … a9 a10,求m的所有正约数的数量sum,输出sum%10. 分析:首先求1~10000内的所有素数,然后分解每一个ai,让对应素数的系数相加得到ei,最后求sum%10=(e1+1) (e2+1) … (e9+1) (e10+1)%10. 涉及算法:素数筛选法及分解质因数 代码: #include <iostream> #include <cmath> #include <cstdio> using namespace std; const int maxn=1001…
2011-06-05 12:49 · Number Theory · 评论(0)