04 2013 档案

摘要:Can you solve this equation?#include #include #include using namespace std; double comp(double x) { return ( 8*pow(x,4) + 7*pow(x,3) + 2*pow(x,2) + 3*x + 6 ); } int main() { int t; double Y; scanf("%d",&t); while( t-- && scanf("%lf",&Y) ) { if( comp(0.0) > Y || 阅读全文
posted @ 2013-04-23 14:18 VeryBigMan 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Bone Collector/* 标准的01背包问题。状态转移方程 f[i][v] = max{f[i-1][v-c[i]]+v[i],f[i-1][v]} */ #include #include #include using namespace std; int main() { int T,N,V,f[1001],vol[1001],val[1001],tem; cin>>T; while(T--) { cin>>N>>V; for(int i=0;i>val[i]; } for(int i=0;i>vol[i]; } memset(f,0 阅读全文
posted @ 2013-04-22 15:56 VeryBigMan 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Max Sum#include using namespace std; int a[100001]; int main() { int T; int i,n,position1,end,thissum,maxsum,begin; cin>>T; for(int tt=1;tt>n; for(i=0;imaxsum) //当前值比最大值大,则头尾都要改 { maxsum=thissum; begin=position1; end=i; } } printf("Case %d:\n%d %d %d\n",tt,maxsum,begin+1,... 阅读全文
posted @ 2013-04-22 15:52 VeryBigMan 阅读(128) 评论(0) 推荐(0) 编辑
摘要:超级楼梯#include using namespace std; int main() { int n; int T; int a[41]; a[1]=0; a[2]=1; a[3]=2; for(int i=4;i>T; while(T--) { cin>>n; cout using namespace std; int main() { int T; long long a[51]; a[1]=1; a[2]=2; for(int i=3;i>T; while(T--) { int A,B; cin>>A>>B; cout using... 阅读全文
posted @ 2013-04-22 15:50 VeryBigMan 阅读(97) 评论(0) 推荐(0) 编辑
摘要:A + B Problem II/* 分析:对于此题做法有两种:其一,使2字符串的中的字符数字减去'0', 逐个相加大于等于10的可以使本位减10,下一位自增1,后面的处理就非常简单了; 其二,便是读入字符串后先让各个字符减'0',一一对应存入整形数组中;之后再相加。 对于2种方法大致是相同的,都要从后面向前加,逢十进位,以及数组初始化均要初始为0, 一边方便运算。 */ #include #include #include using namespace std; int main() { int n,i,len1,len2,j,k,pi,t,flag; ch 阅读全文
posted @ 2013-04-21 20:29 VeryBigMan 阅读(120) 评论(0) 推荐(0) 编辑
摘要:Fibonacci/* 用到了斐波那契数列的通项公式。 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c); 假设给出一个数10234432,那么log10(10234432)=log10(1.0234432*10^7)=log10(1.0234432)+7; log10(1.0234432)就是log10(10234432)的小数部分. log10(1.0234432)=0.010063744 10^0.010063744=1.023443198 那么要取几位就很明显了吧~ 先取对数(对10取),然后得到结果的小数部分bit,pow.. 阅读全文
posted @ 2013-04-21 20:26 VeryBigMan 阅读(135) 评论(0) 推荐(0) 编辑
摘要:最小公倍数#include #include using namespace std; int gcd(int a,int b) { int r; if(a>a>>b) cout #include using namespace std; bool isprime(int n) { for(int i=2;i>n) { while(n--) { cin>>temp; if(isprime(temp)) sum++; } cout #include int biao[1000001]; void fun() { int i,j,k=1; m... 阅读全文
posted @ 2013-04-21 10:30 VeryBigMan 阅读(134) 评论(0) 推荐(0) 编辑
摘要:Moving Tables/*解题思路:这道题最少花多少时间,实际上我们只要考虑哪一段重合度最高, 重合度最高的地方,也就是我们至少要移动的次数了。 因为有400间房间,1-2对应一段走廊,3-4对应一段走廊, 如此我们可以把走廊分成200段,标记为a[1]-a[200], 之后我们根据输进的房间序号,就可以算出要用到哪几段的走廊, 之后给对应的a[n]值加1就好,最后求出a[n]最大值就是移动的次数了。 */ #include #include #include using namespace std; int main() { int T; int pair; int a[201];... 阅读全文
posted @ 2013-04-20 21:10 VeryBigMan 阅读(114) 评论(0) 推荐(0) 编辑
摘要:Elevator#include using namespace std; int main() { int n,temp,last=0,sum,N; while(cin>>n,n!=0) { sum=0; last=0; N=n; while(n--) { cin>>temp; if(temp>last) { sum+=(temp-last)*6; last=temp; } else { sum+=(last-temp)*4; last=temp; } } cout using na... 阅读全文
posted @ 2013-04-20 21:07 VeryBigMan 阅读(91) 评论(0) 推荐(0) 编辑
摘要:A+B for Input-Output Practice (I)#include using namespace std; int main() { int a,b; while(cin>>a>>b) cout using namespace std; int main() { int T; int a,b; cin>>T; while(T--) { cin>>a>>b; cout using namespace std; int main() { int a,b; while(cin>>a>>b,a!=0| 阅读全文
posted @ 2013-04-20 21:03 VeryBigMan 阅读(119) 评论(0) 推荐(0) 编辑