算法
文章平均质量分 73
个人学习算法的一些算法题汇总
小太阳讷~
我还年轻 我讨厌吃苦!
展开
-
51nod 1008 N的阶乘 mod P
1008 N的阶乘 mod P 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题Problem Description输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %)例如:n = 10, P = 11,10! = 36288003628800 % 11 = 10Input两个数N,P,中间用空格隔开。(N <...原创 2018-08-24 15:59:35 · 445 阅读 · 0 评论 -
51nod 1005 大数加法
1005 大数加法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题Problem Description给出2个大整数A,B,计算A+B的结果。Input第1行:大数A第2行:大数B(A,B的长度 <= 10000 需注意:A B有可能为负数)Output输出A + BInput示例6893214758646871...原创 2018-08-24 15:41:52 · 370 阅读 · 0 评论 -
51nod 1004 n^n的末位数字
1004 n^n的末位数字题目来源: Author Ignatius.L (Hdu 1061)基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 Problem Description:给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。Input一个数N(...原创 2018-08-24 15:22:27 · 327 阅读 · 0 评论 -
51 nod 1011 最大公约数GCD (简单题)
1011 最大公约数GCD基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题Problem Description输入2个正整数A,B,求A与B的最大公约数。Input2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)Output输出A与B的最大公约数。Input...原创 2018-08-23 11:27:10 · 291 阅读 · 0 评论 -
POJ 做题的顺序
出处:http://blog.sina.com.cn/s/blog_90c5a1ad01013oax.html初期:一.基本算法:(1)枚举. (poj1753,poj2965)(2)贪心(poj1328,poj2109,poj2586)(3)递归和分治法.(4)递推.(5)构造法.(poj3295)(6)模拟法.(poj1068,poj2632,poj1573,p...转载 2018-08-23 08:49:37 · 427 阅读 · 0 评论 -
HDU 1754 I Hate It (线段树裸题)
I Hate ItTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 102861 ...原创 2018-08-22 16:38:02 · 200 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home
Til the Cows Come HomeTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 72804 Accepted: 24337 DescriptionBessie is out in the...原创 2018-08-15 20:55:56 · 127 阅读 · 0 评论 -
51nod 1006 最长公共子序列 Lcs(传说中的简单题 dp + 记录路径)
1006 最长公共子序列Lcs 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 Problem Description:...原创 2018-08-11 17:54:36 · 194 阅读 · 0 评论 -
LCS LIS
最长上升子序列 (LIS,Longest Increasing Subsequence): 给定一个长度为 n 的数列 a0,a1,a2,...an-1,求该数列中的最长上升子序列。 核心代码一:(两层for循环实现 O(n ^ 2))int n;int a[MAXN], dp[MAXN];scanf("%d", &n);for(int i = 0; i...原创 2018-08-10 19:03:38 · 300 阅读 · 0 评论 -
HDU 2546 饭卡
饭卡 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 41789 Ac...原创 2018-08-09 08:54:34 · 224 阅读 · 0 评论 -
背包问题总结
简单总结一下今天学的背包的相关知识,多有不足之处,还望谅解!!! 背包问题: 部分背包问题 0 1 背包问题 完全背包问题 多重背包问题 1.部分背包问题(可以只取物品的一部分放入背包) 采用直观的贪心策略:优先放入''价量比''(价值除以质量)最大的,直到背包不能再放入(或物品已取完)。2. 0 1 背包问题(每个...原创 2018-08-09 21:03:52 · 1799 阅读 · 0 评论 -
Bone Collector
B - Bone Collector Time limite 1000 ms Memory li...原创 2018-08-08 17:00:27 · 299 阅读 · 0 评论 -
HDU 1260 Tickets
Tickets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S...原创 2018-08-08 07:30:27 · 391 阅读 · 1 评论 -
最大子段和 (dp)
Problem DescriptionN个整数组成的序列a1,a2,a3,…,ann, 求该序列如ai+ai+1+…+aj的连续子段和的最大值。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。Input第1行:整数序列的长度N(2 <= N <= 50000) 第2 - N + 1行:N个整数(-10...原创 2018-08-07 16:32:53 · 778 阅读 · 0 评论 -
POJ 2386 Lake Counting
Lake CountingTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 44936 Accepted: 22205 DescriptionDue to recent rai...原创 2018-08-05 09:55:15 · 163 阅读 · 0 评论 -
POJ 2299 Ultra-QuickSort
Ultra-QuickSortTime Limit: 7000MS Memory Limit: 65536K Total Submissions: 70096 Accepted: 26270 DescriptionIn this problem, you have t...原创 2018-08-03 20:38:02 · 131 阅读 · 0 评论 -
51 nod 1019 逆序数
1019 逆序数基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题Problem Description在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数...原创 2018-08-03 20:24:45 · 247 阅读 · 0 评论 -
51nod 1091 线段的重叠
1091 线段的重叠基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题Problem DescriptionX轴上有N条线段,每条线段包括1个起点和终点。线段的重叠是这样来算的,[10 20]和[12 25]的重叠部分为[12 20]。给出N条线段的起点和终点,从中选出2条线段,这...原创 2018-08-02 21:41:35 · 172 阅读 · 0 评论 -
HDU 1995 汉诺塔V
汉诺塔V Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s):...原创 2018-08-02 15:07:42 · 158 阅读 · 0 评论 -
疯狂的母牛
疯狂的母牛 Time limit 1000 ms Memory limit 32768 kB Problem Description有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?I...原创 2018-08-02 14:32:33 · 275 阅读 · 0 评论 -
HDU 2013 蟠桃记(水题)
蟠桃记 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都觉...原创 2018-08-02 14:20:25 · 317 阅读 · 0 评论 -
POJ 2312 Battle City
Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map t...原创 2018-08-01 18:51:13 · 265 阅读 · 0 评论 -
HDU 1312 Red and Black
Red and Black Time Limit: 2000/1000 MS Memory Limit: 65536/32768 K (Java/Others) Pr...原创 2018-08-01 17:32:24 · 273 阅读 · 0 评论 -
HDU --1873 看病要排队
Problem Description看病要排队这个是地球人都知道的常识。不过经过细心的0068的观察,他发现了医院里排队还是有讲究的。0068所去的医院有三个医生(汗,这么少)同时看病。而看病的人病情有轻重,所以不能根据简单的先来先服务的原则。所以医院对每种病情规定了10种不同的优先级。级别为10的优先权最高,级别为1的优先权最低。医生在看病时,则会在他的队伍里面选择一个优先权最高的人进行...原创 2018-07-28 13:57:02 · 489 阅读 · 0 评论 -
POJ---3348 Cows
Your friend to the south is interested in building fences and turning plowshares into swords. In order to help with his overseas adventure, they are forced to save money on buying fence posts by usin...原创 2018-07-27 19:39:23 · 239 阅读 · 0 评论 -
HDU——1576 A/B 求逆元
题目要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)Output对应每组数据输出(A/B)%9973Sample Input2...原创 2018-07-26 15:45:27 · 286 阅读 · 0 评论 -
E - Integer Divisibility
If an integer is not divisible by 2 or 5, some multiple of that number in decimal notation is a sequence of only a digit. Now you are given the number and the only allowable digit, you should repor...原创 2018-07-25 17:53:50 · 432 阅读 · 0 评论 -
vector (向量)
vector (向量) 定义一个不定长的数组,其长度可以随着用户的需求增加或减少一、头文件:#include <vector>using namespace std;二、声明:a、vector <int> ve; (等价于定义了一个不定长度的 int[ ] 数组 )b、vector <int *> ve; (...原创 2018-07-23 16:48:14 · 201 阅读 · 0 评论 -
CodeForces 519B A and B and Compilation Errors
A and B and Compilation ErrorsA and B are preparing themselves for programming contests.B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile th...原创 2018-07-22 23:59:00 · 299 阅读 · 0 评论 -
HDU 1872-----------------稳定排序
稳定排序 ime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...原创 2018-07-21 18:58:08 · 610 阅读 · 2 评论