随笔分类 - [06] 算法习题
摘要:CSDN 高校俱乐部/英雄会 题目;设数组a包含n个元素恰好是0..n - 1的一个排列,给定b[0],b[1],b[2],b[3]问有多少个0..n-1的排列a,满足(a[a[b[0]]]*b[0]+a[a[b[1]]]*b[1]+a[a[b[2]]]*b[2]+a[a[b[3]]]*b[3])%n==k ?输入包含5个参数:N,K,B0,B1,B2,B3,其中 4#include int b[5];int c[5];int a[15];int aa[15];int vis[15];int n, sum, k;int B_same_num(int b[]){ int i, j; int p
阅读全文
摘要:题目描述:用两个栈来实现一个队列,完成队列的Push和Pop操作。队列中的元素为int类型。输入:每个输入文件包含一个测试样例。对于每个测试样例,第一行输入一个n(1=0)2. POP 从队列中pop一个数。输出:对应每个测试案例,打印所有pop操作中从队列pop中的数字。如果执行pop操作时,队列为空,则打印-1。样例输入:3PUSH 10POPPOP样例输出:10-1题解:应该是考察STL栈应用的一道面试题,还有一点小技巧,不要用两个水杯倒来倒去(如图,明显错误做法)。用一个水杯倒就可以了。代码:C的简洁 && C++的优雅。C代码:#include #include #i
阅读全文
摘要:The ProblemFootball the most popular sport in the world (americans insist to call it "Soccer",but we will call it "Football"). As everyone knows, Brasil is the country that have mostWorld Cup titles (four of them: 1958, 1962, 1970 and 1994). As our national tournament have many t
阅读全文
摘要:题目描述:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为一个整数n(1#include int ino[1002];int pre[1002];typedef struct btnode *btlink;typedef struct btnode{ int data; btlink left; btlink right;}Btn
阅读全文
摘要:题目描述:输入一个链表,从尾到头打印链表每个节点的值。输入:每个输入文件仅包含一组测试样例。每一组测试案例包含多行,每行一个大于0的整数,代表一个链表的节点。第一行是链表第一个节点的值,依次类推。当输入到-1时代表链表输入完毕。-1本身不属于链表。输出:对应每个测试案例,以从尾到头的顺序输出链表每个节点的值,每个值占一行。样例输入:12345-1样例输出:54321代码(一)双链表输出:#include #include typedef struct node *link;typedef struct node{ int data; link pre; link next;}Node;void
阅读全文
摘要:题目1384:二维数组中的查找时间限制:1 秒内存限制:32 兆特殊判题:否提交:7318解决:1418题目描述:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为两个整数m和n(1#include int A[101...
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: NormalDescriptionPlease calculate the answer of A*B, both A and B are integer.InputThe first line of input contains, the number of test cases. There is only line for each test case. It contains two integers.OutputFor e
阅读全文
摘要:背景湖南师大附中成为百年名校之后,每年要接待大批的游客前来参观。学校认为大力发展旅游业,可以带来一笔可观的收入。描述学校里面有N个景点。两个景点之间可能直接有道路相连,用Dist[I,J]表示它的长度;否则它们之间没有直接的道路相连。这里所说的道路是没有规定方向的,也就是说,如果从I到J有直接的道路,那么从J到I也有,并且长度与之相等。学校规定:每个游客的旅游线路只能是一个回路(好霸道的规定)。也就是说,游客可以任取一个景点出发,依次经过若干个景点,最终回到起点。一天,Xiaomengxian决定到湖南师大附中旅游。由于他实在已经很累了,于是他决定尽量少走一些路。于是他想请你——一个优秀的程序
阅读全文
摘要:Judge InfoMemory Limit: 65536KBCase Time Limit: 3000MSTime Limit: 3000MSJudger: Number Only JudgerDescriptionWithin Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted wilderness.You are employed by
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: NormalDescriptionPlease calculate the answer of A+B and the answer of A-B, both A and B are integer.InputThe first line of input contains, the number of test cases. There is only line for each test case. It contains tw
阅读全文
摘要:1. 将代码存放到 GitHub , 不然找起来很不方便。2. 集训时,上午看书总结,下午开始刷题。重质不重量。3. 由于SZUOJ 英文晦涩难懂,先从Vijos 开始刷起。4. 每次刷完题后,花10分钟总结一下。不然等于白刷。5. 保持简洁,唯美的风格。6. 每天睡觉前来这里总结一下一天的收获。
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 5000MSTime Limit: 5000MSJudger: Float Numbers (1e-4) JudgerDescriptionThe chemists are well known because of their weird. Especially when they add water or salt in the same beaker over and over again. Moreover, the still hope you can tell him the mass
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 1000MSTime Limit: 1000MSJudger: Number Only JudgerDescription现在假设:2进制对应的基数是0,1;3进制对应的基数是0,1,2;……10进制对应的基数是0,1,2,3,4,5,6,7,8,9.……n进制对应的基数是0,1,2,3,……,n-1;你的任务是实现进制之间的转换。Input第一行,有t(t 2 #include 3 4 char str[1000];//输入字符串 5 int start[500],ans[500],res[5..
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: Number Only JudgerDescriptionA number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321 is a palindrome; the number 77778 is not. Of course, palindromes hav
阅读全文
摘要:DescriptionThere is a company that makes plastic digits which are primarily put on the front door of each house to form the house number. In order to make sure that they don’t waste any resources, they want to make the exact number of digits for the house numbers needed. You are to write a program t
阅读全文
摘要:进制转换Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18495Accepted Submission(s): 10386Problem Description输入一个十进制数N,将它转换成R进制数输出。Input输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(210)。Output为每个测试实例输出转换后的数,每个输出占一行。如果R大于10,则对应的数字规则参考16进制(比如,10用A表示,等等)。Sample In
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: NormalDescriptionA boy and a girl both like studying code in their extra-curricular. Of course, they like each other. Therefore, the boy shows his love to the girl one day. The girl smiles and leaves a series of Morse
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: Number Only JudgerDescriptionFrog Frank likes 30 more than likes 40, yet he likes 12 and 39 equally. This is because he likes numbers that have a lot of different prime factors. For example, 30 have 3 prime factors (2,
阅读全文
摘要:描述某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:1) 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;2) 五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;3) 成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;4) 西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;5) 班级贡献奖,每人850元,班级评议成绩高于80分(>8
阅读全文
摘要:Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: NormalDescriptionAn anagram is formed by rearranging the letters of a word. You are given a string, please find out if it is an anagram of a word or not. No word will have have more than 50 characters.InputThe input wi
阅读全文

浙公网安备 33010602011771号