poj 1472(递归模拟)】的更多相关文章

题意:就是让你求出时间复杂度. 分析:由于指数最多为10次方,所以可以想到用一个数组保存各个指数的系数,具体看代码实现吧! 代码实现: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; ][]; ]; int num; struct node{ ]; void init() { memset(sum,,sizeof(su…
Instant Complexity Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1908   Accepted: 658 Description Analyzing the run-time complexity of algorithms is an important tool for designing efficient programs that solve a problem. An algorithm…
题目:http://poj.org/problem?id=1472 这个题目是分到“模拟题”一类的,我觉得模拟的成分比较少,主要考察编程能力.独立写完这个题特别兴奋...所以我必须好好说一说,独家哦... 题意是计算一段伪代码的时间复杂度,整体代码夹在“BEGIN”和“END”之间,中间有很多循环语句,夹在“LOOP X”和“END”之间,表示循环X次.第一眼一看很难下手,其实只要想到一点这个题就非常水了: “BEGIN”语句可以看做”LOOP 1“. 这样的话整个程序的递归结构就明显了,就是L…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://poj.org/problem? id=3077 Description For a given number, if greater than ten, round it to the nearest ten, then (if that result is greater than 100) take the…
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; int ind[45]; bool used[45]; int r[21]; int l[21]; int len,n,llen; int w[21]; int main(){ int t; scanf("%d",&t); while(t--){ memset(used,0,siz…
水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x==y)就是说接下来进站的正好是要出去的,那就直接让它A—>B 否则 if(C不空 && y=(最后进入C的火车)) 让车从C开出进入B  否则 if(x!=0)那么车 A—>C 否则  无解 #include<cstdio> #include<cstring>…
模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostream> #include <cstring> using namespace std; ], b[], c[]; void Cal() { memset(c, , sizeof(c)); ; i < ; i++) ; j < ; j++) c[i+j] += a[i] * b[j]…
e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看discuss里好想被坑的人还不少.总天数能直接整除260的时候.年数要减1. 不喜欢做模拟.....5555.... 附代码: #include<stdio.h>#include<string.h>#include<iostream>#include<string>…
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure that the robots reach their destinations without crashing into each other. Of course, all warehouses are rectangular, and all robots occup…
P3719 [AHOI2017初中组]rexp 没有什么算法的题做起来真不适应,这道题深深讽刺了我想用栈维护匹配括号个数的想法: 递归解决就行了: 时刻注意函数返回值是什么,边界条件是什么: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; typedef double dd; typedef long long ll; ll n; ll a[maxn]; ll i…