
算法
文章平均质量分 66
tokers
所有的魅力在“习惯”面前都将无色。
展开
-
Codeforces Round #226 (Div. 2) E---Bear in the Field(矩阵)
Our bear’s forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let’s deno原创 2015-03-19 16:38:47 · 1031 阅读 · 0 评论 -
hdu2276---Kiki & Little Kiki 2(矩阵)
Problem Description There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and oth原创 2015-03-12 21:56:22 · 846 阅读 · 0 评论 -
hdu2842---Chinese Rings(矩阵)
Problem Description Dumbear likes to play the Chinese Rings (Baguenaudier). It’s a game played with nine rings on a bar. The rules of this game are very simple: At first, the nine rings are all on the原创 2015-03-12 16:05:25 · 1353 阅读 · 0 评论 -
hdu4686---Arc of Dream(矩阵)
Problem Description An Arc of Dream is a curve defined by following function:where a0 = A0 ai = ai-1*AX+AY b0 = B0 bi = bi-1*BX+BY What is the value of AoD(N) modulo 1,000,000,007?Input There ar原创 2015-03-12 17:11:24 · 1731 阅读 · 0 评论 -
hdu1588---Gauss Fibonacci(矩阵,线性递推)
根据题意:最后就是求f(b) + f(k + b) + f(2 * k + b) + …+ f((n-1) * k + b) 显然f(b) = A^b 其中A = 1 1 1 0 所以sum(n - 1) = A^b(E + A^ k + A ^(2 * k) + … + A ^((n - 1) * k) 设D = A^k sum(n-1) = A^b(E +原创 2015-03-12 19:29:58 · 767 阅读 · 0 评论 -
Codeforces Round #116 (Div. 2, ACM-ICPC Rules)---E. Cubes
Let’s imagine that you’re playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that d原创 2015-03-30 20:25:55 · 1037 阅读 · 0 评论 -
POJ3061---Subsequence(尺取法)
Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal lengt原创 2015-03-30 14:50:36 · 796 阅读 · 0 评论 -
POJ3320---Jessica's Reading Problem(尺取法)
DescriptionJessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all原创 2015-03-30 21:23:47 · 1010 阅读 · 0 评论 -
hust1384---The value of F[n]
DescriptionFor any integer i>=3 we have F[i]=(F[i-1]+2*F[i-2]+3*F[i-3])%9901;Now give you F[0],F[1],F[2],can you tell me the value of FInputFist Line, an integer Q(1<=Q<=100) represent the number of原创 2015-03-12 14:08:19 · 814 阅读 · 0 评论 -
hdu4565---So Easy!(矩阵)
Problem Description A sequence Sn is defined as:Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn. You, a top coder, say: So easy!Input原创 2015-03-14 11:32:19 · 1202 阅读 · 0 评论 -
hdu2294---Pendant (矩阵)
Problem Description On Saint Valentine’s Day, Alex imagined to present a special pendant to his girl friend made by K kind of pearls. The pendant is actually a string of pearls, and its length is defi原创 2015-03-11 19:33:11 · 814 阅读 · 0 评论 -
hdu2243---考研路茫茫——单词情结(AC自动机+矩阵+二分)
首先对2^64取模的话,可以直接用unsigned long long,这样溢出部分就是取模后的结果了 方法类似POJ2778传送门 只不过这里要统计长度不超过m的方案 我们先统计出长度为m的所有方案,然后减去不包含这些串的方案,剩下就是至少包含一个串的方案了 设转移矩阵为A 相当于sum = A + A^2 + … A^m f(m) = f(m / 2) * (1 + A原创 2015-03-11 12:42:08 · 1107 阅读 · 0 评论 -
hdu1575---Tr A
Problem Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。Input 数据的第一行是一个T,表示有T组数据。 每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据。接下来有n行,每行有n个数据,每个数据的范围是[0,9],表示方阵A的内容。Output 对应每组数据,输出Tr(A原创 2015-03-10 19:28:22 · 1391 阅读 · 0 评论 -
hdu4965---Fast Matrix Calculation(矩阵)
Problem Description One day, Alice and Bob felt bored again, Bob knows Alice is a girl who loves math and is just learning something about matrix, so he decided to make a crazy problem for her.Bob has原创 2015-03-16 18:31:46 · 854 阅读 · 0 评论 -
POJ2774---Long Long Message(后缀数组,求最长公共子串)
Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway t原创 2015-03-26 16:36:16 · 992 阅读 · 0 评论 -
hdu4549---M斐波那契数列(矩阵+欧拉定理)
Problem Description M斐波那契数列F[n]是一种整数数列,它的定义如下:F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 )现在给出a, b, n,你能求出F[n]的值吗?Input 输入包含多组测试数据; 每组数据占一行,包含3个整数a, b, n( 0 <= a, b, n <= 10^9 )Output 对每组测试原创 2015-03-16 20:44:43 · 1053 阅读 · 0 评论 -
POJ3150---Cellular Automaton(矩阵)
DescriptionA cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of discrete time steps according to a set of rules that describe the new state of a c原创 2015-03-17 21:29:15 · 926 阅读 · 0 评论 -
Codeforces Round #113 (Div. 2)E---Tetrahedron(矩阵,水题)
You are given a tetrahedron. Let’s mark its vertices with letters A, B, C and D correspondingly.An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn’t stay idle.原创 2015-03-21 11:14:38 · 1147 阅读 · 0 评论 -
hdu1757---A Simple Math Problem(矩阵)
Problem Description Lele now is thinking about a simple function f(x).If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0<=i<=9) can only be 0原创 2015-03-11 20:33:29 · 779 阅读 · 0 评论 -
POJ2778---DNA Sequence(AC自动机+矩阵)
Description It’s well known that DNA Sequence is a sequence only contains A, C, T and G, and it’s very useful to analyze a segment of DNA Sequence,For example, if a animal’s DNA sequence contains segm原创 2015-03-10 21:55:09 · 914 阅读 · 0 评论 -
hdu2604---Queuing(AC自动机+矩阵)
Problem Description Queues and Priority Queues are data structures which are known to most computer scientists. The Queue occurs often in our daily life. There are many people lined up at the lunch ti原创 2015-03-10 21:17:54 · 682 阅读 · 0 评论 -
POJ3233---Matrix Power Series(矩阵快速幂+二分)
DescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.InputThe input contains exactly one test case. The first line of input contains three positive integers原创 2015-03-10 20:13:51 · 751 阅读 · 0 评论 -
Codeforces Round #172 (Div. 2)---D. Maximum Xor Secondary(RMQ + 二分)
Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1, x2, …, xk (k > 1) is such maximum element xj, that the following in原创 2015-04-03 14:17:50 · 1122 阅读 · 0 评论 -
SPOJ687---REPEATS - Repeats(后缀数组+RMQ)
A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the strings = abaabaabaabais a (4,3)-repeat with t = aba as its seed原创 2015-04-07 19:43:33 · 908 阅读 · 0 评论 -
Codeforces Round #218 (Div. 2)---D. Vessels(并查集)
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of th原创 2015-04-09 21:45:31 · 868 阅读 · 0 评论 -
POJ2082---Terrible Sets(单调栈)
Description Let N be the set of all natural numbers {0 , 1 , 2 , … }, and R be the set of all real numbers. wi, hi for i = 1 … n are some elements in N, and w0 = 0. Define set B = {< x, y > | x, y ∈原创 2015-05-07 20:52:48 · 850 阅读 · 0 评论 -
POJ3494---Largest Submatrix of All 1’s(单调栈)
DescriptionGiven a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.InputThe input contains multiple test cases.原创 2015-05-08 14:46:49 · 896 阅读 · 0 评论 -
Codeforces Round #305 (Div. 2)D---Mike and Feet(单调栈)
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-t原创 2015-05-27 20:09:25 · 970 阅读 · 0 评论 -
Codeforces Round #303 (Div. 2)
A.简单题/************************************************************************* > File Name: A.cpp > Author: ALex > Mail: zchao1995@gmail.com > Created Time: 2015年05月20日 星期三 09时51分15秒原创 2015-05-21 14:45:33 · 753 阅读 · 0 评论 -
hdu5245---Joyful(期望)
Problem Description Sakura has a very magical tool to paint walls. One day, kAc asked Sakura to paint a wall that looks like an M×N matrix. The wall has M×N squares in all. In the whole problem we den原创 2015-05-28 13:45:03 · 1648 阅读 · 0 评论 -
POJ2773---Happy 2006(容斥+二分)
Description Two positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9…are all relatively prime to 2006.Now your job is eas原创 2015-05-28 19:46:17 · 810 阅读 · 0 评论 -
hdu5246---超级赛亚ACMer(贪心)
Problem Description 百小度是一个ACMer,也是一个超级赛亚人,每个ACMer都有一个战斗力,包括百小度。 所谓超级赛亚人的定义,是说如果在对抗中刚好接近极限状态,那就会激发斗志,实力提升.具体来说,就是百小度现在要接受一些ACMer的挑战了,这些ACMer有n个人,第i个人的战斗力是a[i]。 百小度接下来可以自主安排与这n个ACMer的PK顺序,他要想在PK赛中赢过另外一个原创 2015-05-31 13:06:47 · 1147 阅读 · 0 评论 -
hdu5248---序列变换(二分答案+贪心)
Problem Description 给定序列A={A1,A2,…,An}, 要求改变序列A中的某些元素,形成一个严格单调的序列B(严格单调的定义为:Bi/************************************************************************* > File Name: hdu5248.cpp > Author: ALex原创 2015-05-31 13:08:49 · 1650 阅读 · 0 评论 -
LightOJ1006---Hex-a-bonacci(矩阵快速幂)
Given a code (not optimized), and necessary inputs, you have to find the output of the code for the inputs. The code is as follows:int a, b, c, d, e, f;int fn( int n ) { if( n == 0 ) return a;原创 2015-06-03 21:47:34 · 1086 阅读 · 0 评论 -
POJ3250---Bad Hair Day(单调栈)
DescriptionSome of Farmer John’s N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see t原创 2015-05-07 19:02:30 · 766 阅读 · 0 评论 -
NOJ1175---Dress, Left Dress!(单调栈)
Maybe you think this problem is about girls and ladies. But you’re wrong. ‘Left dress’ means ‘Eyes left’. It’s used in armed forces. It will make a square more orderly. Now several soldiers stand in原创 2015-05-07 18:19:37 · 745 阅读 · 0 评论 -
POJ2796---Feel Good(前缀和+单调栈维护)
Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people’s memories about some period of li原创 2015-05-07 19:45:04 · 1522 阅读 · 0 评论 -
topcoder-srm-613-div2
250分: 简单题,判断C A T这三个字符的个数就行了/************************************************************************* > File Name: 250.cpp > Author: ALex > Mail: zchao1995@gmail.com > Created Ti原创 2015-05-08 22:43:11 · 793 阅读 · 0 评论 -
hdu5225---Tom and permutation(规律,枚举+乱搞)
Problem Description Tom has learned how to calculate the number of inversions in a permutation of n distinct objects by coding, his teacher gives him a problem: Give you a permutation of n distinct i原创 2015-05-09 22:25:11 · 1452 阅读 · 0 评论 -
hdu1505---City Game(单调栈)
Problem Description Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,fa原创 2015-05-10 22:22:01 · 603 阅读 · 0 评论