Metal Steak

Hard to eat

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 79 Stories :: 0 Comments :: 0 Trackbacks

公告

aaaaaaaaaaaa

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

#include <iostream>
using namespace std;

const int delta[4][2= { { 2-1 }, { 21 }, { 1-2 }, { 12 } };
int
sourcer, sourcec, targetr, targetc, srow, scol;

struct
highp
{
    
int n[101];
    
void
    
operator += ( highp h )
    {
        n[
0= h.n[0> n[0? h.n[0] : n[0];
        
forint i = 1; i <= n[0]; i++ )
            n[i] 
+= h.n[i];
        
forint i = 1; i <= n[0]; i++ )
        {
            n[i 
+ 1+= n[i] / 10;
            n[i] 
%= 10;
        }
        
if( n[n[0+ 1> 0 )
            n[
0]++;
    }
}ans[
51][51];

ostream
&
operator << ( ostream& out, highp h )
{
    
forint i = h.n[0]; i > 0; i-- )
        
out << h.n[i];
    
return out;
}

void
__read__()
{
    cin 
>> scol >> srow
        
>> sourcec >> sourcer
        
>> targetc >> targetr;
}

void
__search__()
{
    memset( ans, 
0sizeof ans );
    ans[sourcer][sourcec].n[
0= ans[sourcer][sourcec].n[1= 1;
    
forint j = 0; j <= scol; j++ )
        
forint i = 0; i <= srow; i++ )
            
forint k = 0; k < 4; k++ )
            {
                
int
                r 
= i + delta[k][1],
                c 
= j + delta[k][0];
                
if( r > 0 && r <= srow
                 
&& c > 0 && c <= scol )
                    ans[r][c] 
+= ans[i][j];
            }
}

void
__outp__()
{
    cout 
<< ans[targetr][targetc] << endl;
}

int
main()
{
    __read__();
    __search__();
    __outp__();

    
return 0;
}

posted on 2009-09-15 21:04 mad4alcohol 阅读(84) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理