The Fourth Dimension Space

枯叶北风寒,忽然年以残,念往昔,语默心酸。二十光阴无一物,韶光贱,寐难安; 不畏形影单,道途阻且慢,哪曲折,如渡飞湍。斩浪劈波酬壮志,同把酒,共言欢! -如梦令

#

论小人&论苏轼作品中的生命艺术

先占个空位 文章正在酝酿中...

posted @ 2010-03-20 01:21 abilitytao 阅读(145) | 评论 (0)编辑 收藏

提纲

提纲提纲提纲提纲提纲提纲提纲提纲提纲提纲提纲 GRE ,我快疯了,倒计时21天!加油!!!!!!!

posted @ 2010-03-19 13:48 abilitytao 阅读(123) | 评论 (0)编辑 收藏

TC 464 DIV 2 1000 穷搜所有状态

     摘要:      #include<iostream>#include<algorithm>#include<vector>using namespace std;char str[100][100];int v[100][100];int n,m;int vv[100...  阅读全文

posted @ 2010-03-17 01:14 abilitytao 阅读(1199) | 评论 (1)编辑 收藏

浙大A题 我无语了。。。

 

#include<iostream>
#include
<algorithm>
#include
<cstring>
using namespace std;
int dp[1<<16];


int main()
{

    
int n,m;
    
int i,j;
    
while(scanf("%d%d",&n,&m)!=EOF)
    
{
        memset(dp,
0,sizeof(int)*(1<<n));
        
int num;
        
for(i=1;i<=m;i++)
        
{
            scanf(
"%d",&num);
            
int t=0;
            
int k;
            
for(j=1;j<=num;j++)
            
{
                scanf(
"%d",&k);
                t
|=(1<<(k-1));
            }

            dp[t]
=1;
        }

        
int res=0;
        
int NN=(1<<n)-1;
        
int x;
        
for(i=1;i<=NN;i++)
        
{
            x
=i;
            
while(x)
            
{
                x
=(x-1)&i;
                dp[i]
=max(dp[i],dp[x]+dp[(~x)&(i)]);
            }

        }

        
for(i=1;i<=NN;i++)
        
{

            
if(dp[i]>res)
                res
=dp[i];
        }

        printf(
"%d\n",res);
    }

    
return 0;
}

谢谢 我是智障 大牛的提示。

posted @ 2010-03-15 14:32 abilitytao 阅读(173) | 评论 (0)编辑 收藏

frustration

cheer up,my friend,no body will gain without paying ,do as best as you can ,this is the answer.
Maybe this semester ,You have a lots of things to do , It is doesn't matter what the circumstance is.Insist yourself , and stand up.

posted @ 2010-03-15 13:36 abilitytao 阅读(117) | 评论 (0)编辑 收藏

最近的一些比赛

 
OJ Name Start Time  
Topcoder SRM 464 2010-03-16 23:00:00  
HDU  2010年河北大学程序设计竞赛 2010-03-20 13:00:00  
JLU 2010 JLU Contest Warmup I 2010-03-20 18:00:00  
Codeforces Codeforces Beta Round #5 2010-03-21 00:00:00  
FZU FOJ有奖月赛-2010年03月 2010-03-21 13:00:00  
Topcoder Member SRM 465 2010-03-26 09:00:00  
HDU  今天你AC了吗——HDOJ2010公开练习赛(一) 2010-03-27 12:00:00  
JLU 2010 JLU Contest Warmup II 2010-03-27 18:00:00  
HDU  HDOJ Monthly Contest – 2010.04.03 2010-04-03 12:00:00  
JLU 2010 JLU Contest Warmup III 2010-04-03 18:00:00  
Topcoder SRM 466 2010-04-04 00:00:00  
ZJU The 10th Zhejiang University Programming Contest 2010-04-10 13:30:00  
JLU 2010 JLU Contest Warmup IV 2010-04-10 18:00:00  
UVA First new season 2010 contest 2010-04-10 23:00:00  
Topcoder SRM 467 2010-04-16 09:00:00  
Topcoder Member SRM 468 2010-04-20 19:00:00  
Google Google Code Jam 24 hr Qualification Round 2010-05-08 07:00:00 推荐
Google Google Code Jam Round 1A 2010-05-22 09:00:00  
Google Google Code Jam Round 1B 2010-05-23 00:00:00  
Google Google Code Jam Round 1C 2010-05-23 17:00:00  
Google Google Code Jam Round 2 2010-06-05 22:00:00  
Google Google Code Jam Round 3 2010-06-12 22:00:00  
BUPT Warm Up ? 2012-12-21 20:00:00  

上次更新时间:2010-03-17 11:31:07
所有比赛按照开始时间排序。目前支持自动获取 HDU, PKU, TJU, FZU, UVA, ECNU, HUST, HRBEU, SGU, HIT, JLU, USTC, Topcoder, SPOJ, BUPT, ZJU, Codeforces, NUAA ,其他功能陆续添加,发现bug请报告。其中TopCoder只选取本月和下月的SRM(Single Round Match)。所有的比赛开始时间已经换算为北京时间。比赛也可以由特殊用户手动添加。所有比赛将在比赛开始后24小时自动删除,也可以手动提前删除。

posted @ 2010-03-14 11:45 abilitytao 阅读(292) | 评论 (0)编辑 收藏

博弈问题几种类型(转)

 

一)巴什博弈(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。

很容易想到当n%(m+1)<>0时,先取必胜,第一次先拿走n%(m+1),以后每个回合到保持两人拿走的物品总和为m+1即可。

这个游戏还可以有一种变相的玩法:两个人轮流报数,每次至少报一个,最多报十个,谁能报到100者胜。

 

(二)威佐夫博弈(Wythoff Game):有两堆各若干个物品,两个人轮流从某一堆或同时从两堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜。

如果甲面对(0,0),那么甲已经输了,这种局势我们称为奇异局势。前几个奇异局势是:(0,0)、(1,2)、(3,5)、(4,7)、(6,10).可以看出,a0=b0=0,ak是未在前面出现过的最小自然数,而 bk=ak+k.

    那么任给一个局势(a,b),怎样判断它是不是奇异局势呢?我们有如下公式:

    ak =[k(1+√5)/2],bk= ak + k  (k=0,1,2,...,n 方括号表示取整函数)

奇妙的是其中出现了黄金分割数(1+√5)/2 = 1。618...,因此,由ak,bk组成的矩形近似为黄金矩形,由于2/(1+√5)=(√5-1)/2,可以先求出j=[a(√5-1)/2],若a=[j(1+√5)/2],那么a = aj,bj = aj + j,若不等于,那么a = aj+1,bj+1 = aj+1+ j + 1,若都不是,那么就不是奇异局势。然后再按照上述法则进行,一定会遇到奇异局势。

 

(三)尼姆博弈(Nimm Game):有三堆各若干个物品,两个人轮流从某一堆取任意多的物品,规定每次至少取一个,多者不限,最后取光者得胜。

对于任何奇异局势(a,b,c),都有a^b^c=0.

非奇异局势(a,b,c)(a<b<c)转换为奇异局势,只需将c变为a^b,即从c中减去 c-(a^b)即可。

posted @ 2010-03-14 00:42 abilitytao 阅读(394) | 评论 (0)编辑 收藏

我对DP问题的一些粗浅理解,希望大家多多批评指正。

动态规划——思想者的游戏
/Files/abilitytao/DP2.rar

posted @ 2010-03-13 23:11 abilitytao 阅读(243) | 评论 (0)编辑 收藏

POJ 2184 Cow Exhibition 一维DP,需要转化和平移

      这题其实和普通的DP题没什么区别,只是需要用dp[i]表示i状态下能够达到的最大值,而且由于有负数,需要将坐标轴整体平移一下。
在一进一步说,还是要求出所有的状态,类似穷举了。我想了下,如果真的要优化,可以只将出现过的状态记下来,这样扫描的时候可以剪去一些时间,也许0MS就是这么做的吧^_^ ,复杂度O(10^7)。
代码如下:
#include<iostream>
#include
<algorithm>
using namespace std;
#define INF 999999999
int dp[400001];
int n;
int l,r;
#define OFFSET 200000

int main()
{
    fill(dp,dp
+400001,-INF);
    dp[OFFSET]
=0;
    l
=r=OFFSET;
    scanf(
"%d",&n);
    
int i,j;
    
int a,b;
    
for(i=1;i<=n;i++)
    
{
        scanf(
"%d%d",&a,&b);
        
if(a<=0&&b<=0)
            
continue;
        
if(a<0)
        
{

            
int k;
            
for(k=l;k<=r;k++)
            
{

                
if(dp[k]!=-INF)
                
{
                    
if(k+a<l)
                        l
=k+a;

                    
if(dp[k+a]==-INF)
                        dp[k
+a]=dp[k]+b;
                    
else
                        dp[k
+a]=max(dp[k+a],dp[k]+b);
                }

            }

        }


        
else
        
{
            
int k;
            
for(k=r;k>=l;k--)
            
{

                
if(dp[k]!=-INF)
                
{
                    
if(k+a>r)
                        r
=k+a;

                    
if(dp[k+a]==-INF)
                        dp[k
+a]=dp[k]+b;
                    
else
                        dp[k
+a]=max(dp[k+a],dp[k]+b);
                }

            }


        }

    




    }

    
int res=0;
    
int k;
    
for(k=OFFSET;k<=OFFSET+1000*n;k++)
    
{

        
if(dp[k]>0&&k-OFFSET+dp[k]>res)
            res
=k-OFFSET+dp[k];
    }

    printf(
"%d\n",res);
    
return 0;
}

posted @ 2010-03-13 00:24 abilitytao 阅读(1580) | 评论 (0)编辑 收藏

POJ 1384 Piggy-Bank 完全背包

重温了下 背包九讲 不仅发现了其中的一些错误 也发现了这篇文章的局限性,例如这个题。。。做完之后 我对背包的概念又模糊了。。。
#include<iostream>
using namespace std;

int dp[10001];
int w[10001];
int v[10001];
int main()
{

    
int t;
    
int e,f;
    
int n;
    
int ww;
    scanf(
"%d",&t);
    
int i,j,k;
    
for(i=1;i<=t;i++)
    
{
        scanf(
"%d%d",&e,&f);
        ww
=f-e;
        scanf(
"%d",&n);
        
for(j=1;j<=n;j++)
            scanf(
"%d%d",&v[j],&w[j]);
        memset(dp,
-1,sizeof(dp));
        dp[
0]=0;
        
for(j=1;j<=n;j++)
        
{

            
for(k=0;k<=ww-w[j];k++)
            
{

                
if(dp[k]!=-1)
                
{

                    
if(dp[k+w[j]]==-1)
                        dp[k
+w[j]]=dp[k]+v[j];
                    
else
                        dp[k
+w[j]]=min(dp[k+w[j]],dp[k]+v[j]);
                }

            }

        }

        
if(dp[ww]==-1)
            printf(
"This is impossible.\n");
        
else
            printf(
"The minimum amount of money in the piggy-bank is %d.\n",dp[ww]);





    }

    
return 0;
}

posted @ 2010-03-08 21:19 abilitytao 阅读(1704) | 评论 (2)编辑 收藏

仅列出标题
共42页: First 18 19 20 21 22 23 24 25 26 Last