07 2017 档案
摘要:#include <iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; int cmp(int a,int b) { return a>b; } i
阅读全文
摘要:1 /*#include <iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 using namespace std; 6 7 int main() 8 { 9 long long n; 10 int a
阅读全文
摘要:ACM 所有算法 数据结构 栈,队列,链表 哈希表,哈希数组 堆,优先队列双端队列可并堆左偏堆 二叉查找树Treap伸展树 并查集集合计数问题二分图的识别 平衡二叉树 二叉排序树 线段树一维线段树二维线段树 树状数组一维树状数组N维树状数组 字典树 后缀数组,后缀树 块状链表 哈夫曼树 桶,跳跃表
阅读全文
摘要:对于迷宫一般维护参数为当前这个点的坐标x,y以及当前走过的步数。判断是否到达某个点就是判断当前坐标是否等于目标坐标。若不等于,继续搜索,正常迷宫一般有四个方向可以走,可以定义一个方向数组int next[4][2]={{0,1},{1,0},{0,-1},{-1,0}}; (→ /↓/ ← / ↑)
阅读全文
摘要:dij贪心地取min(cur,pre)最大的路径 或者直接按权值排序,贪心地从最小或最大取,并茶几加点,联通停止即可。。。 我们还可以用二分。。就是二分最大边权或者最小边权。。重复上面类似kruskal的过程 k短路。。次小生成树。。可持久化堆 dij本质还是个贪心地过程 求满足某条件的最短路径或最
阅读全文
摘要:例如:一个字符串 awbcdewgh 他的子串: awbc、awbcd、awbcde ...很多个子串 ,但是都是连续在一起 。 他的子序列: abc 、abcd、 abcde ... 很多个子序列 ,但是子序列中的字符在字符串中不一定是连在一起的,而是删除其中若干个, 但是子序列一定是单调的(即字
阅读全文
摘要:J - Java Beans There are N little kids sitting in a circle, each of them are carrying some java beans in their hand. Their teacher want to select M ki
阅读全文
摘要:H - Hard to Play MightyHorse is playing a music game called osu!. After playing for several months, MightyHorsediscovered the way of calculating score
阅读全文
摘要:B - Break Standard Weight The balance was the first mass measuring instrument invented. In its traditional form, it consists of a pivoted horizontal l
阅读全文
摘要:A - Applications https://vjudge.net/contest/174208#overview Recently, the ACM/ICPC team of Marjar Universitydecided to choose some new members from fr
阅读全文
摘要:不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16913 Accepted Submission(
阅读全文
摘要:一只小蜜蜂... Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 54056 Accepted Submission(s): 19544 Prob
阅读全文
摘要:折线分割平面 http://acm.hdu.edu.cn/showproblem.php?pid=2050 Problem Description 我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可
阅读全文
摘要:原文链接:http://www.nowamagic.NET/librarys/veda/detail/2314 /** * 观察归纳法我们发现:递归的数学模型就是归纳法: * 归纳法适用于把一个问题转换为他的子问题,而他的子问题又转化为子问题; * 而且我们发现这些问题都有一个模型:存在相同的逻辑归
阅读全文
摘要:漫谈递归思想 编程里面估计最让人摸不着头脑的基本算法就是递归了。很多时候我们看明白一个复杂的递归都有点费时间,尤其对模型所描述的问题概念不清的时候,想要自己设计一个递归那么就更是有难度了。今天我也花费了半个小时来搞明白二叉树的平衡性的递归模型,首先我不明白什么叫做平衡性,所以花费的时候大部分实在试探
阅读全文
摘要:A - Surprising Strings 题意就是给你一个字符串,例如ZGBG,有一种称谓叫D-unique 这个字符串 在D=0时, 有三个子串 ZG GB BG,因为这三个都不同,也就是unique,所以ZGGB是 0-unique; 同理 D=1时,有两个子串ZB GG也是不同,所以ZGG
阅读全文
摘要:Function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Problem De
阅读全文
摘要:Expectation Division Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s):
阅读全文
摘要:Colorful Tree Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Probl
阅读全文
摘要:Division Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Prob
阅读全文
摘要:Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Probl
阅读全文
摘要:Add ‘em Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4144 Accepted Submission(s): 2976 Problem
阅读全文
摘要:Rock, Paper, or Scissors? Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2927 Accepted Submissio
阅读全文
摘要:a/b + c/d Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14895 Accepted Submission(s): 7761 Prob
阅读全文
摘要:又见GCD Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19497 Accepted Submission(s): 8129 Problem
阅读全文
摘要:#include #include #include #include using namespace std; int cmp(int x)//计算因子数 { int cnt=0; for(int j=1;j maxn) { maxn=cmp(i); index=i; ...
阅读全文
摘要:#include #include #include #include using namespace std; int main() { int t; int n,k; int x; int i; int a[2005],hash[2005]; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); ...
阅读全文
摘要:FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has
阅读全文
摘要:1 /*这是一个模拟题,模拟一种台球的进球过程,并且判定胜负。 2 对于输入的字符串,如果出现R则红方记1分,如果出现Y则黄方记1分。 3 最后根据哪一方打进黑球和得分情况判定胜负。 4 程序说明: 5 这里给出两个C语言程序,一个没有使用数组(正解),另外一个是使用了数组来存储字符串。 6 函数scanf()不会读走数后面的'\n',所有需要用函数getchar()读取'\n'(扔...
阅读全文
摘要:The expression N!, read as "N factorial," denotes the product of the first N positive integers, where N is nonnegative. So, for example, N N! 0 1 1 1
阅读全文
摘要:Given a positive integer N, you should output the leftmost digit of N^N. InputThe input contains several test cases. The first line of the input is a
阅读全文
摘要:调试方法: F5 开始调试 Shift+F5 停止调试 F10 单步调试, F11 跟进到所有代码的函数内部 Shift+F11 从当前函数中跳出 F9 设置(取消)断点 Alt+F9 高级断点设置 ctrl+F10 运行到光标处
阅读全文
摘要:距离ACM/ICPC的时间越来越少了,选择性地看一些集训队论文是很有必要的。 (在此给已经看过所有论文的神牛跪了= =)http://www.cnblogs.com/AbandonZHANG/archive/2012/07/21/2601889.html 所以,我在此整理了一下,供大家参考。
阅读全文
摘要:听说刷完初级,省赛铜牌就没问题了···加油吧 初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,p
阅读全文
摘要:ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考。 菜鸟之作,大牛勿喷,如有不当或补充之处,欢迎指出。 本建议书分为三个阶段,大一、大二、大三。大四暂没整理
阅读全文
摘要:ACM题集以及各种总结大全! 虽然退役了,但是整理一下,供小弟小妹们以后切题方便一些,但由于近来考试太多,顾退役总结延迟一段时间再写!先写一下各种分类和题集,欢迎各位大牛路过指正。 一.ACM入门 关于ACM 百度百科连接 杭州电子科技大学(hdu)ACM题目 连接 关于acm的帮助 连接 北京大学
阅读全文
摘要:Acmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz h
阅读全文
摘要:Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown in the figure. For example, 1, 2, and 3 has been
阅读全文
摘要:前m大的数 Problem Description 还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。 给定一个包含N(N<=3000)个正整
阅读全文
摘要:今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的 考生,并将他们的成绩按降序打印。 Input测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N <
阅读全文
摘要:输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。 你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。 Input输入包含多组测试
阅读全文
摘要:1.有一个字符串,如何判断这个字符串中是否含有某个字符串? 答:比如string str = “abcdffdf.pdf”;如何判断这个字符串中是否含有cd,cd出现了几次。 可以用 strstr()来判断是否存在。存在时,可以跳过第一个找到的“cd”,继续查找,以统计次数。 或者STL加上stri
阅读全文
摘要:#include #include #include int main() { double a,b,c,d,m; int t; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf",&a,&b,&c,&d); m=sqrt((a-c)*(a-c)+(b-d)*(b-d)); ...
阅读全文
摘要:/* 给你一个小数x,让你算出小数点后第n位是什么,(1 #include #include #include using namespace std; int main() { int t; char a[105]; int n; scanf("%d",&t); while(t--) { scanf("%s%d",a,&n...
阅读全文
摘要:/* 他开始在他的院子种竹子,第1个月种1根竹子,第2个月种8根竹子,第3个月种27根竹子 ...第N个月就种(N^3)根竹子.当他种下第X根竹子那一刻,就是他重出江湖之时! 告诉你X的值, 你能算出逐青的复出会是在第几个月吗? Input 首先输入一个t,表示有t组数据,跟着t行. 每行是一个整数X,X #include int main() { int n; scanf("%d"...
阅读全文
摘要:/* 欲找出三人所在逐个击破, 现在他发现威士忌的位置s,天外来客的位置u, 不过很难探查到亦纷菲v所在何处,只能知道三人满足关系: arctan(1/s) = arctan(1/u)+arctan(1/v) 注:(其中0 想计算的值 */ #include #include #include #include #include using namespace std; int main() ...
阅读全文
摘要:这道题目意思很明白,有不确定的数据沙包和陷阱,还要排序···那就必须要用结构体+数组
阅读全文
摘要:第二小整数 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11541 Accepted Submission(s): 7097 Problem
阅读全文
摘要:奇偶位互换 Problem Description 给定一个长度为偶数位的0,1字符串,请编程实现串的奇偶位互换。 Input 输入包含多组测试数据;输入的第一行是一个整数C,表示有C测试数据;接下来是C组测试数据,每组数据输入均为0,1字符串,保证串长为偶数位(串长<=50)。 Output 请为
阅读全文
摘要:轻松通过墓碑,进入古墓后,才发现里面别有洞天。突然,Yifenfei发现自己周围是黑压压的一群蝙蝠,个个扇动翅膀正准备一起向他发起进攻!形势十分危急!好在此时的yifenfei已经不是以前那个经常被lemon抢走MM的菜鸟了!面对众多蝙蝠的嗜血狂攻,只见yifenfei使出轻灵的剑法,刷,刷,刷,瞬
阅读全文
摘要:#include #include #include #include using namespace std; int main() { int t; char a[55],b[55],r[120];//b插入a中央 scanf("%d",&t); while(t--) { scanf("%s%s",a,b);//可以用gets int...
阅读全文
摘要:Parity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1855 Accepted Submission(s): 1447 Problem
阅读全文
摘要:declaration of 'int a' shadows a parameter :函数参数里,已经有这两个名称的变量了,指定义了同名的参数,造成了隐藏。 expected primary-expression before '[' token|:定义struct sqstack {...}结构
阅读全文
摘要:#include #include #include #include using namespace std; const int maxn=20017; int s[maxn]; int main() { int n,m; int i,j; memset(s,0,sizeof(s)); /*s[1]=1;//埃筛素数 for(i=2; i maxx) ...
阅读全文
摘要:#include #include #include using namespace std; const char inst[] = "ABLR"; const int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int main(void) { int t = 0; char s[5][6]; char c...
阅读全文
摘要:#include #include int main(void) { int n,stlen,i,j; char carr[1000]; while(scanf("%d",&n)!=EOF) { while(n--) { scanf("%s",carr); stlen=strlen(c...
阅读全文
摘要:Problem A: Good Joke! Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 25 Solved: 16[Submit][Status][Web Board] Description Vadim and Roman like discussi
阅读全文
摘要:/*这是一题贪心,题目大意是蝎子要搬家,第个实例第一行T有一个数,表示的是实例的个数,接下来T个实例,每个实例第一行有两个数V和N,分别表示新家的空间和接下来有N个物品要搬,接下来有N行,第一行有两个数,分别表示这件物品所占的空间,把这件物品搬进家里所需要的空间。所以我们要按照物品所占空间和物品搬进
阅读全文
摘要:Problem E: Subarray GCD Description Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such thatGCD of all integ
阅读全文
摘要:Description 输入一个正整数n,求有几对素数x,y,满足n=x+y((3,2)和(2,3)视为相同的素数对)。 输入一个正整数n,求有几对素数x,y,满足n=x+y((3,2)和(2,3)视为相同的素数对)。 Input 有多组数据,每行输入一个偶整数n(3<n<32768)。n等于0时,
阅读全文
摘要:#include #include #include using namespace std; int main(void) { int s,m,i; /*int seed=0; int a[10005]={0}; //memset(a,0,sizeof(a));*/ while(scanf("%d%d",&s,&m)!=EOF); { ...
阅读全文
摘要:#include #include int main(void) { int n ; //freopen("input.txt" , "r" , stdin); //freopen("output.txt" , "w" , stdout); scanf("%d" , &n); while(n--) { int N ; int i ; int count[10...
阅读全文
摘要:#include #include int main() { int t,i,num; char a[]={'C','H','O','N'}; double n[]={12.01,1.008,16.00,14.01};//此所谓之常量数组的妙用 char s[105]; double sum; scanf("%d",&t); whil...
阅读全文
摘要:1 #include 2 #include 3 int main() 4 { 5 char s[100]; 6 scanf("%s",s); 7 int sum=0; 8 int cnt=0; 9 for(int i=0;i<strlen(s);i++) 10 { 11 if(s[i]=='O') 12 ...
阅读全文
摘要:1. 利用数学公式lg(n!)=lg(2)+lg(3)+....+lg(n) 求解 2.
阅读全文
摘要:题目要求一个数至少出现(n+1)/2次。用cnt来记录解出现的次数,出现了正确解就令cnt自增1,不是正确解就使cnt自减1。 那么,正确解对应的cnt一定是不小于1的。可以用一个极端的例子来说明下:输入3 3 3 3 3 3 2 1 5 6 8,开始当ans=3时,cnt=6, 那么继续执行num
阅读全文
摘要:#include int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); while(N--) { cas=1;//必须在这儿初始化cas,坑 while(scanf("%d%d",&n,&m),n||m) { ...
阅读全文
摘要:1 #include 2 #include 3 4 int main() 5 { 6 int i, count = 0, j, k, a[10], c;//用i表示abc,j表示def,k表示ghi 7 memset(a, 0, sizeof(a));//初始化数组,全部为零 8 for ( i=123; i<=329; i++ ) 9 {...
阅读全文
摘要:1 #include //基础版 2 #define MAX 110 3 4 int main(void) 5 { 6 int a, b, c; 7 scanf("%d %d %d",&a,&b,&c); 8 9 int integer = a/b; 10 int remainderTemp=a%b; 11 int arr[MAX];...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 main() 6 { 7 long long n,m,c,i;//相乘可能为大数! 8 double sum; 9 while(~scanf("%lld%lld",&n,&m),n||m) 10 { 11 sum=...
阅读全文
摘要:https://wenku.baidu.com/view/0febf66859fafab069dc5022aaea998fcc2240aa.html
阅读全文
摘要:Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 79180 Accepted Submission(s): 24760
阅读全文
摘要:解题报告:输入一个年月日,让你求出那一天是星期几,但是做这题之前必须先了解一点历史。首先在1582年之前,判断是否是闰年的标准是只要能被四整除就是闰年, 然后在1752年9月2号的后的11天被抹去了,也就是说1752年9月2号的第二天不是9月3号,而是9月14号。然后知道这些这题就好做了,我的做法是
阅读全文
摘要:欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。 基本算法:设a=qb+r,其中a,b,q,r都是整数,则gcd(a,b)=gcd(b,r),即gcd(a,b)=gcd(b,a%b)。 递归版算法: 递归优化版: 迭代版: 扩展欧几里德算法 基本算法:对于不完全为 0 的非负整数 a
阅读全文
摘要:2017-07-14 23:37:11 1.本书亮点:总结典型错误;必须一个字节都不差,程序才能算通过。这对于培养严谨、周密的程序设计作风极为有效, 学生必须考虑到每一个细节和特殊边界条件,而不是大体上正确就过。传统的人工评判是难以做到这一点的储空间的内容,最终得到问题的解答来解决实际问题。 3.一
阅读全文
摘要:基础-北大实践/算法设计题集 枚举-妙趣75 / 啊哈57/黑书/花书第三章/北大157 贪心-妙趣84/黑书13/算法之道71/算导222/花书第九章 递归与分治-妙趣78/黑书19/算道29/算导16,38/花书第五章/北大173 递推-黑书28 以上/数据结构与算法分析第十章 基础教程1-7
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 char s[100005],t[100005]; 6 int cmp(char *s1,char *s2) 7 { 8 int i,j,l1,l2; 9 l1=strlen(s1),l2=strlen(s2); 10 for...
阅读全文
摘要:涉及到字符串的问题,无外乎这样一些算法和数据结构:自动机 KMP算法 Extend-KMP 后缀树 后缀数组 trie树 trie图及其应用。当然一般的字符串问题中,我们只要用简单的暴力算法就可以解决了,然后如果暴力效率太低,就用个hash。 输入输出: C语法: char buf[20]; get
阅读全文
摘要:B. Keyboard Layouts time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output B. Keyboard Layouts t
阅读全文
摘要:1 #include 2 int n,a[100007]; 3 int main(){ 4 scanf("%d",&n); 5 for(int i=1;i1&&a[R] 2 using namespace std; 3 int N; 4 int V[105]; 5 int main() 6 { 7 cin>>N; 8 for(int i=1...
阅读全文
摘要:快速幂定义: 1.快速幂就是快速算底数的n次幂。其时间复杂度为 O(log₂N), 与朴素的O(N)相比效率有了极大的提高。用法:用于求解 a 的 b 次方,而b是一个非常大的数,用O(n)的复杂度会超时。那么就需要这个算法,注意它不但可以对数求次幂,而且可用于矩阵快速幂。--百度百科 2.所谓的快
阅读全文
摘要:素数定义: 质数(prime number)又称素数,有无限个。质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数,这样的数称为质数。例 子:2、3、5、7、11、13、17、19。(那时候还有一种说法叫做“质数”,但是就语言上来说,我觉得“素数”这种叫法和“合数”比较搭配,类比于“化学
阅读全文
摘要:puts()函数 puts()函数用来向标准输出设备(屏幕)写字符串并换行, 其调用格式为: puts(s); 其中s为字符串变量(字符串数组名或字符串指针)。 puts()函数的作用与语printf("%s\n", s)相同。 gets()函数 gets()函数用来从标准输入设备(键盘)读取字符串
阅读全文
摘要:B. Black Square time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp has a checkered
阅读全文
摘要:A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a small restauran
阅读全文
摘要:怎么把hh:mm:ss.45 时间格式换算成秒? 比较简单点的格式,比如hh:mm:ss是比较容易的,但是怎么样把hh:mm:ss.45,这样的格式,就是秒不是整数的时间格式换算成秒? 怎么把hh:mm:ss.45 时间格式换算成秒? 比较简单点的格式,比如hh:mm:ss是比较容易的,但是怎么样把
阅读全文