码迷,mamicode.com
首页 >  
搜索关键字:ans    ( 3741个结果
wikioi 1251--括号
题目描述:给定n个变量,求乘积的表达式的个数。相邻元素相乘需要加*号。思路:直接递归即可,ans[i][j] = ans[i][k]+ans[k+1][j](i 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 u...
分类:其他好文   时间:2014-07-07 23:26:00    阅读次数:178
matlab取整 四舍五入
Matlab取整函数有: fix, floor, ceil, round.取整函数在编程时有很大用处。一、取整函数1.向零取整(截尾取整)fix-向零取整(Round towards zero);>> fix(3.6) ans = 32.向负无穷取整(不超过x 的最大整数-高斯取整)floor-向负...
分类:其他好文   时间:2014-07-07 21:11:49    阅读次数:198
POJ_2299 Ultra-QuickSort【归并排序】
题目链接:http://poj.org/problem?id=2299 题目大意:求出排序过程中的最小交换次数 利用归并排序的分治算法解决此题。 代码: #include #include #include #define N 500001 using namespace std; int a[N]; int temp[N]; long long ans; void merge(in...
分类:其他好文   时间:2014-06-30 08:18:11    阅读次数:230
hdu 4122 Alice's mooncake shop (线段树)
题目大意: 一个月饼店每个小时做出月饼的花费不一样。 储存起来要钱,最多存多久。问你把所有订单做完的最少花费。 思路分析: ans = segma( num[]*(cost[] + (i-j)*s) ) 整理一下会发现式子就是   cost[]-j*s + i*s  对于每一个订单,我们把i拿出来分析 所以也就用cost - j*s 建树。 然后在储存期间找到最小的花费就...
分类:其他好文   时间:2014-06-30 08:12:10    阅读次数:133
最长上升子序列模板
//最长上升子序列(n^2) //入口参数:1.数组名称 2.数组长度(从0开始) int LIS(int a[],int len) { int *dp=new int[len]; int ans=1; dp[0]=1; for(int i=1;i<len;i++) { int m=0; for(int j=0;jm && a[j]<a...
分类:其他好文   时间:2014-06-28 09:19:23    阅读次数:220
uva 10844 - Bloques(数论+高精度)
题目链接:uva 10844 - Bloques 题目大意:给出一个n,表示有1~n这n个数,问有多少种划分子集的方法。 解题思路:递推+高精度。 1 1 2 2 3 5 5 7 10 15 15 20 27 37 52 dp[i][j]=dp[i?1][j?1]+dp[i][j?1]dp[i][0]=dp[i?1][i?1]ans[i]=dp[i][i] ...
分类:其他好文   时间:2014-06-28 08:24:45    阅读次数:235
Codeforces 10C Digital Root 规律题
题目链接:点击打开链接 #include #include #include #include #include #include #include #include #include #include using namespace std; #define N 1000005 #define ll __int64 ll num[10],n; ll go(ll x){ ll ans ...
分类:其他好文   时间:2014-06-26 07:31:44    阅读次数:191
HDU4641_K-string
若它的一个子串出现的次数不少于K次,那么这个子串就是一个K-string。现给出原串,每次可以向该串后面添加一个字符或者询问当前有多少个不同的K-string。在线添加查询,解法直指SAM。其实给添加函数直接设置一个返回值直接更新ans就好了。对于每个状态,多开一个值记录它的出现次数,每次添加点过后...
分类:其他好文   时间:2014-06-25 16:48:37    阅读次数:145
SDOI2012Longge的问题
题解:代码: 1 var i:longint; 2 n,k,ans:int64; 3 procedure main; 4 begin 5 readln(n); 6 ans:=n; 7 for i:=2 to trunc(sqrt(n)) do 8 if n mod i=0 the...
分类:其他好文   时间:2014-06-25 15:55:52    阅读次数:204
待修改 nyoj 412
测试好多数据都正确,一直wrong ans 仔细思考 #include#include//x&-x 为x的二进制中最低位1的权值 列: 110010为 2 11100为4 ,所以 log2(4)表示最低位1在第2位using namespace std;int lowbit(int n){ retu...
分类:其他好文   时间:2014-06-24 14:29:45    阅读次数:150
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!