摘要: //背包问题:f[v]=max(f[v],f[v-cost]+weight)#include<iostream>#define max(a,b) a>b?a:busing namespace std;int c[300000],i,k,sum,a[110],b[110],n;//01背包void bag(int cost,int weight){for(i=sum/2;i>=cost;i--)c[i]=max(c[i],c[i-cost]+weight);}//完全背包void complete(int cost,int weight){for(i=cost;i< 阅读全文
posted @ 2012-07-27 15:44 疼痛落在指尖 阅读(169) 评论(0) 推荐(0)
摘要: /*求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。2 312 66789 100000 089841*///思路:当幂集超过6位之后对1000求余值不变。#include<iostream>using namespace std;int main(){int a,b;while(cin>>a>>b){if(a== 阅读全文
posted @ 2012-07-27 08:47 疼痛落在指尖 阅读(190) 评论(0) 推荐(0)