首页 > 其他 > 详细

【总结】2014新生暑假个人排位赛01

时间:2014-07-19 08:01:38      阅读:408      评论:0      收藏:0      [点我收藏+]
时间限制 1000 ms 内存限制 65536 KB

题目描述

学姐在加入集训队之后,学习了使用ubuntu系统来做题,但是没有了360电脑管家,学姐再也没办法看到她的飞速电脑开机到底虐了全国多少人。作为一个电脑高手,学姐花了几分钟黑到了360的数据库拿到了全国360用户的开机时间,现在学姐想自己算算到底打败了百分之多少的人?

输入格式

输入有多组数据。首先给出数据组数T(T10),下面T组数据,每组开头为n(1n100000),360的用户数,和t,学姐的开机时间,接下来n个数字,ti代表第i个用户的开机时间。其中tti为非负整数且小于109

输出格式

每组数据一行,输出学姐打败了全国百分之多少的用户,精确到小数点后两位。

输入样例

1
5 3
1 1 2 2 3

输出样例

80.00%
这题数据有问题,,,越大的反而越快
水题,一炮
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int num[111111];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("D:/in.txt","r",stdin);
        //freopen();
    #endif
    int T;
    scanf("%d",&T);
    while(T--)
    {
 
        int n,s;
        scanf("%d%d",&n,&s);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",num+i);
        }
        sort(num+1,num+1+n);
        int i=1;
        for(i=1;i<=n;i++)
        {
            if(num[i]>=s)
                break;
        }
        //cout<<"i::"<<i<<endl;
        double ans=(i-1)*1.0/n;
        printf("%.2f",ans*100);
        cout<<"%\n";
    }
    return 0;
}

时间限制 1000 ms 内存限制 65536 KB

题目描述

趁着放假,学姐去学车好带学弟去兜风。但是学车真的很辛苦,每天五点半就要起床赶班车,但是学姐的教练更辛苦,他们要相同的时间到而且日日如此。于是温柔的学姐关切的问了他们的休息情况,教练告诉她,他们两个人倒班教学姐,每个教练每上n天班就会放一天假,如果一个教练放假,就由另一个教练来代课,一直代课到自己放假再换人。 现在学姐想知道,每一天是哪个教练给她上课。

输入格式

输入开始为数据组数T(T10),接下来T组输入,第一行为nm,我们假设第一天教学姐的是教练1,而且他教学姐的前一天刚刚放完假,教练2则会在学姐上课的第m天放假,1mn 以保证每天都有教练教学姐。接下一行为q(q103),即询问次数,接着q行,每行ti表示学姐想问哪天的教练是谁。因为教练们非常非常厉害,而且学姐不知道自己到底会花多久学完车,你的程序要处理的nmti上限为109

输出格式

对于每个询问ti,输出一行,1或2代表当天的教练。

输入样例

1
5 3
3
6
9
13

输出样例

2
1
2
签到题,一炮,逻辑题,命名挺优雅
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int num[111111];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("D:/in.txt","r",stdin);
        //freopen();
    #endif
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        int oneZero=n+1;
        int oneShi=m+n+1;
        int relativeShi_one=oneShi-oneZero;
        int twoZero=m;
        int twoShi=n+1;
        int relativeShi_two=twoShi-twoZero;
        int len=n+1;
        int quesnum;scanf("%d",&quesnum);
        int ques;
        for(int i=1;i<=quesnum;i++)
        {
            scanf("%d",&ques);
            if(ques<=n)
            {
                printf("1\n");
                continue;
            }
            int inONE=(ques-n-1)%len;
            int inTWO=(ques-m)%len;
            if(inONE==0)
                printf("2\n");
            else if(inONE<relativeShi_one)
                printf("2\n");
            else
                printf("1\n");
        }
    }
    return 0;
}

时间限制 1000 ms 内存限制 65536 KB

题目描述

学姐正在写作业,但是她写着写着就开始想学弟,走神的她就开始在纸上画圈圈。这时学弟突然出现了,好奇的学弟问学姐在做什么,惊慌之下,学姐随口说想算一下这些圆覆盖的面积为多少。学弟顿时非常仰慕学姐,但是学姐突然意识到自己不会做,为了自己能给学弟留下好印象,她来求助你帮她算出来这些圆覆盖的面积。
为了简化问题,我们假设所有圆的半径都为1。

输入格式

输入有多组数据。开头为一个整数T(T10),表示数据组数,接下来T组输入,每组开头为一个整数n(1n100),表示学姐画的圆的个数,接下来n行,每行两个整数xi,yi,表示圆的圆心坐标,1xi,yi100

输出格式

输出一个数,表示面积并,精确到小数点后五位。

输入样例

1
2
1 1
2 1

输出样例

5.05482
这题,初始是全零的整点阵,把圆心都标记为1,然后,面积只有3种情况你懂得,遍历所有4个点组成的格子,看4个点的圆心分布情况
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <cstring>
const double pi=acos(-1.0);
using namespace std;
int g[111][111];
int main()
{
    int T;scanf("%d",&T);
    double sq1=0.25*pi;
    double sq2=pi/6+sqrt(3)/4;
    while(T--)
    {
        memset(g,0,sizeof(g));
        int num;scanf("%d",&num);
        for(int i=1;i<=num;i++)
        {
            int x,y;scanf("%d%d",&x,&y);
            g[x][y]=1;
        }
        double ans=0;
        for(int i=0;i<=100;i++)
        {
            for(int j=0;j<=100;j++)
            {
                double tttt=ans;
                int ss=g[i][j]+g[i+1][j]+g[i][j+1]+g[i+1][j+1];
                if(ss==1)
                {
                    ans+=sq1;
                }
                else if(ss>2)
                {
                    ans+=1;
                }
                else if(ss==2&&((g[i][j]==1&&g[i+1][j+1]==1)||(g[i][j+1]==1&&g[i+1][j]==1)))
                {
                    ans+=1;
                }
                else if(ss==2)
                {
                    ans+=sq2;
                }
            }
        }
        printf("%.5f\n",ans);
    }
    return 0;
}

时间限制 1000 ms 内存限制 65536 KB

题目描述

给定一个N?M的矩阵,求问里面有多少个由‘#‘组成的矩形,"There are 5 ships.",若是里面有一个不是矩形的联通块,则输出"So Sad"

输入格式

1n,m1000

有多组数据,EOF结束。

输出格式

每行对应一个answer

输入样例

6 8
.....#.#
##.....#
##.....#
.......#
#......#
#..#...#
6 8
.....#.#
##.....#
###...##
.......#
##.....#
#..#...#

输出样例

There are 5 ships.
So Sad
听贺爷说了个神方法
bubuko.com,布布扣扫描所有的点(.),如果有这样的情况,那就肯定是非连通的。否则, 数左上角的sharp个数就可以了,输出答案
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <cstring>
using namespace std;
#define N 111111<div class="line number6 index5 alt1"><code class="cpp preprocessor">#include <iostream></code></div><div class="line number7 index6 alt2"><code class="cpp preprocessor">#include <cstdio></code></div><div class="line number8 index7 alt1"><code class="cpp preprocessor">#include <cmath></code></div><div class="line number9 index8 alt2"><code class="cpp preprocessor">#include <cstdlib></code></div><div class="line number10 index9 alt1"><code class="cpp preprocessor">#include <cmath></code></div><div class="line number11 index10 alt2"><code class="cpp preprocessor">#include <algorithm></code></div><div class="line number12 index11 alt1"><code class="cpp preprocessor">#include <stack></code></div><div class="line number13 index12 alt2"><code class="cpp preprocessor">#include <vector></code></div><div class="line number14 index13 alt1"><code class="cpp preprocessor">#include <cstring></code></div><div class="line number15 index14 alt2"><code class="cpp keyword bold">using</code> <code class="cpp keyword bold">namespace</code> <code class="cpp plain">std;</code></div><div class="line number16 index15 alt1"><code class="cpp preprocessor">#define N 111111</code></div><div class="line number17 index16 alt2"><code class="cpp color1 bold">char</code> <code class="cpp plain">g[1111][1111];</code></div><div class="line number18 index17 alt1"><code class="cpp color1 bold">int</code> <code class="cpp plain">main()</code></div><div class="line number19 index18 alt2"><code class="cpp plain">{</code></div><div class="line number20 index19 alt1"><code class="cpp spaces">    </code><code class="cpp color1 bold">int</code> <code class="cpp plain">n,m;</code></div><div class="line number21 index20 alt2"><code class="cpp spaces">    </code><code class="cpp keyword bold">while</code><code class="cpp plain">(</code><code class="cpp functions bold">scanf</code><code class="cpp plain">(</code><code class="cpp string">"%d%d"</code><code class="cpp plain">,&n,&m)!=EOF)</code></div><div class="line number22 index21 alt1"><code class="cpp spaces">    </code><code class="cpp plain">{</code></div><div class="line number23 index22 alt2"><code class="cpp spaces">            </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number24 index23 alt1"><code class="cpp spaces">            </code><code class="cpp plain">{</code></div><div class="line number25 index24 alt2"><code class="cpp spaces">                </code><code class="cpp functions bold">scanf</code><code class="cpp plain">(</code><code class="cpp string">"%s"</code><code class="cpp plain">,g[i]);</code></div><div class="line number26 index25 alt1"><code class="cpp spaces">            </code><code class="cpp plain">}</code></div><div class="line number27 index26 alt2"><code class="cpp spaces">            </code><code class="cpp color1 bold">bool</code> <code class="cpp plain">isout=</code><code class="cpp keyword bold">false</code><code class="cpp plain">;</code></div><div class="line number28 index27 alt1"><code class="cpp spaces">            </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number29 index28 alt2"><code class="cpp spaces">            </code><code class="cpp plain">{</code></div><div class="line number30 index29 alt1"><code class="cpp spaces">                </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">j=0;j<m;j++)</code></div><div class="line number31 index30 alt2"><code class="cpp spaces">                </code><code class="cpp plain">{</code></div><div class="line number32 index31 alt1"><code class="cpp spaces">                    </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i][j]==</code><code class="cpp string">'.'</code><code class="cpp plain">)</code></div><div class="line number33 index32 alt2"><code class="cpp spaces">                    </code><code class="cpp plain">{</code></div><div class="line number34 index33 alt1"><code class="cpp spaces">                            </code><code class="cpp keyword bold">if</code><code class="cpp plain">((g[i-1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i-1][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number35 index34 alt2"><code class="cpp spaces">                                </code><code class="cpp plain">(g[i+1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number36 index35 alt1"><code class="cpp spaces">                                </code><code class="cpp plain">(g[i][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i+1][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">)||</code></div><div class="line number37 index36 alt2"><code class="cpp spaces">                                </code><code class="cpp plain">(g[i-1][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i-1][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j+1]==</code><code class="cpp string">'#'</code><code class="cpp plain">))</code></div><div class="line number38 index37 alt1"><code class="cpp spaces">                                </code><code class="cpp plain">{</code></div><div class="line number39 index38 alt2"><code class="cpp spaces">                                    </code><code class="cpp functions bold">printf</code><code class="cpp plain">(</code><code class="cpp string">"So Sad\n"</code><code class="cpp plain">);</code></div><div class="line number40 index39 alt1"><code class="cpp spaces">                                    </code><code class="cpp plain">isout=</code><code class="cpp keyword bold">true</code><code class="cpp plain">;</code></div><div class="line number41 index40 alt2"><code class="cpp spaces">                                    </code><code class="cpp keyword bold">break</code><code class="cpp plain">;</code></div><div class="line number42 index41 alt1"><code class="cpp spaces">                                </code><code class="cpp plain">}</code></div><div class="line number43 index42 alt2"><code class="cpp spaces">                    </code><code class="cpp plain">}</code></div><div class="line number44 index43 alt1"><code class="cpp spaces">                </code><code class="cpp plain">}</code></div><div class="line number45 index44 alt2"><code class="cpp spaces">                </code><code class="cpp keyword bold">if</code><code class="cpp plain">(isout)</code></div><div class="line number46 index45 alt1"><code class="cpp spaces">                    </code><code class="cpp keyword bold">break</code><code class="cpp plain">;</code></div><div class="line number47 index46 alt2"><code class="cpp spaces">            </code><code class="cpp plain">}</code></div><div class="line number48 index47 alt1"><code class="cpp spaces">            </code><code class="cpp keyword bold">if</code><code class="cpp plain">(isout)</code></div><div class="line number49 index48 alt2"><code class="cpp spaces">                </code><code class="cpp keyword bold">continue</code><code class="cpp plain">;</code></div><div class="line number50 index49 alt1"><code class="cpp spaces">            </code><code class="cpp color1 bold">int</code> <code class="cpp plain">countn=0;</code></div><div class="line number51 index50 alt2"><code class="cpp spaces">            </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">i=0;i<n;i++)</code></div><div class="line number52 index51 alt1"><code class="cpp spaces">            </code><code class="cpp plain">{</code></div><div class="line number53 index52 alt2"><code class="cpp spaces">                </code><code class="cpp keyword bold">for</code><code class="cpp plain">(</code><code class="cpp color1 bold">int</code> <code class="cpp plain">j=0;j<m;j++)</code></div><div class="line number54 index53 alt1"><code class="cpp spaces">                </code><code class="cpp plain">{</code></div><div class="line number55 index54 alt2"><code class="cpp spaces">                    </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i][j]==</code><code class="cpp string">'#'</code><code class="cpp plain">)</code></div><div class="line number56 index55 alt1"><code class="cpp spaces">                    </code><code class="cpp plain">{</code></div><div class="line number57 index56 alt2"><code class="cpp spaces">                        </code><code class="cpp keyword bold">if</code><code class="cpp plain">(g[i-1][j]!=</code><code class="cpp string">'#'</code><code class="cpp plain">&&g[i][j-1]!=</code><code class="cpp string">'#'</code><code class="cpp plain">)</code></div><div class="line number58 index57 alt1"><code class="cpp spaces">                        </code><code class="cpp plain">{</code></div><div class="line number59 index58 alt2"><code class="cpp spaces">                            </code><code class="cpp plain">countn++;   </code></div><div class="line number60 index59 alt1"><code class="cpp spaces">                        </code><code class="cpp plain">}</code></div><div class="line number61 index60 alt2"><code class="cpp spaces">                    </code><code class="cpp plain">}</code></div><div class="line number62 index61 alt1"><code class="cpp spaces">                </code><code class="cpp plain">}</code></div><div class="line number63 index62 alt2"><code class="cpp spaces">            </code><code class="cpp plain">}</code></div><div class="line number64 index63 alt1"><code class="cpp spaces">            </code><code class="cpp functions bold">printf</code><code class="cpp plain">(</code><code class="cpp string">"There are %d ships.\n"</code><code class="cpp plain">,countn);</code></div><div class="line number65 index64 alt2"><code class="cpp spaces">    </code><code class="cpp plain">}</code></div><div class="line number66 index65 alt1"><code class="cpp spaces">    </code><code class="cpp keyword bold">return</code> <code class="cpp plain">0;</code></div><div class="line number67 index66 alt2"><code class="cpp plain">}</code></div>
char g[1111][1111];
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
            for(int i=0;i<n;i++)
            {
                scanf("%s",g[i]);
            }
            bool isout=false;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(g[i][j]=='.')
                    {
                            if((g[i-1][j]=='#'&&g[i-1][j-1]=='#'&&g[i][j-1]=='#')||
                                (g[i+1][j]=='#'&&g[i+1][j-1]=='#'&&g[i][j-1]=='#')||
                                (g[i][j+1]=='#'&&g[i+1][j]=='#'&&g[i+1][j+1]=='#')||
                                (g[i-1][j]=='#'&&g[i-1][j+1]=='#'&&g[i][j+1]=='#'))
                                {
                                    printf("So Sad\n");
                                    isout=true;
                                    break;
                                }
                    }
                }
                if(isout)
                    break;
            }
            if(isout)
                continue;
            int countn=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(g[i][j]=='#')
                    {
                        if(g[i-1][j]!='#'&&g[i][j-1]!='#')
                        {
                            countn++;  
                        }
                    }
                }
            }
            printf("There are %d ships.\n",countn);
    }
    return 0;
}

时间限制 5000 ms 内存限制 65536 KB

题目描述

用关系“<”和“=”将3个数A、B和C依序排列时有13种不同的序关系:
ABCABCABCABCACBACBBAC

BACBCABCACABCABCBA

现在输入数字的个数,要求你给出上述关系的数目。

数的个数不大于100
 

输入格式

多组数据,EOF结束

每行一个输入

输出格式

对于每个输入,输出一行,即对应答案

输入样例

3

输出样例

13
dp,方程看程序,用大数模板
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <cstring>
using namespace std;
class BigInteger
{
public:
    int num[100];
    int maxlenn;
    int len;
 
    BigInteger()
    {
        maxlenn=300;
        len=0;
        memset(num,0,sizeof(num));
    }
 
    BigInteger(char* ss)
    {
        maxlenn=300;
        len=0;
        memset(num,0,sizeof(num));
        int& i=this->len;
        int lenofss=strlen(ss);
        char s[10]={0};
        for(i=0;lenofss/4;lenofss-=4)
        {
            strncpy(s,ss+lenofss-4,4);
            this->num[i++]=atoi(s);
        }
        if(lenofss)
        {
            memset(s,0,sizeof(s));
            strncpy(s,ss,lenofss);
            this->num[i++]=atoi(s);
        }
    }
 
    BigInteger(int s)
    {
        maxlenn=300;
        len=0;
        memset(num,0,sizeof(num));
        while(s>10000)
        {
            num[len++]=s%10000;
            s/=10000;
        }
        if(s)
        {
            num[len++]=s;
        }
    }
 
    void Print()
    {
        int i;
        printf("%d",num[len-1]);
        for(i=this->len-2;i>=0;i--)
        {
            printf("%04d",this->num[i]);
        }
        printf("\n");
    }
 
    BigInteger Times(BigInteger sec)//该数本身没有变化,只是返回了结果
    {
        int i,j,jw;
        BigInteger ans;
        for(i=0;i<len;i++)
        {
            jw=0;
            ans.len=i;
            for(j=0;j<sec.len;j++)
            {
                jw+=this->num[i]*sec.num[j]+ans.num[ans.len];
                ans.num[ans.len++]=jw%10000;
                jw/=10000;
            }
            while(jw)
            {
                jw+=ans.num[ans.len];
                ans.num[ans.len++]=jw%10000;
                jw/=10000;
            }
        }
        return ans;
    }
 
    BigInteger plusone()
    {
        int i=0;
        do
        {
            num[i]++;
            num[i+1]+=num[i]/10000;
            num[i]%=10000;
            i++;
        }while(num[i]<9999);
        return *this;
    }
 
    BigInteger operator+(const BigInteger& sec)
    {
        bool isUp=false;
        BigInteger tmp=*this;
        int maxn=tmp.len>sec.len?tmp.len:sec.len;
        for(int i=0;i<maxn;i++)
        {
            /*if(isUp)
            {
                tmp.num[i]++;
                if(tmp.num[i]>=10000)
                {
                    tmp.num[i]=0;
                    isUp=true;
                }
            }*/
            if(tmp.num[i]+sec.num[i]<=9999)
            {
                tmp.num[i]+=sec.num[i];
                if(isUp)
                {
                    tmp.num[i]++;
                    isUp=false;
                    if(tmp.num[i]==10000)
                    {
                        tmp.num[i]=0;
                        isUp=true;
                    }
                }
            }
            else
            {
                tmp.num[i]=tmp.num[i]+sec.num[i]-10000;
                if(isUp)
                {
                    tmp.num[i]++;
                }
                isUp=true;
            }
        }
        if(isUp)
            tmp.num[maxn]=1;
        if(tmp.num[maxn]!=0)
            tmp.len++;
        else
            tmp.len=maxn;
        return tmp;
    }
 
    BigInteger operator-(const BigInteger& sec)//big-small
    {
        bool isBorrow=false;
        BigInteger tmp=*this;
        for(int i=0;i<this->len;i++)
        {
            if(isBorrow)
            {
                tmp.num[i]-=1;
                if(tmp.num[i]<0)
                    tmp.num[i]=9999;
            }
            if(tmp.num[i]<sec.num[i])
            {
                tmp.num[i]=tmp.num[i]+10000-sec.num[i];
                isBorrow=true;
            }
            else
            {
                tmp.num[i]-=sec.num[i];
                isBorrow=false;
            }
        }
        int i=0;
        for(i=maxlenn-1;;i--)
        {
            if(tmp.num[i]!=0)
                break;
        }
        if(i==0)
            tmp.len=1;
        else
            tmp.len=i+1;
        return tmp;
    }
 
    BigInteger operator*(const BigInteger sec)
    {
        return this->Times(sec);
    }
 
    int operator/(const BigInteger& sec)//big/small
    {
        BigInteger tmp=*this;
        int ans=0;
        while(tmp>=sec)
        {
            tmp=tmp-sec;
            ans++;
        }
        return ans;
    }
 
    BigInteger operator%(const BigInteger& sec)
    {
        BigInteger tmp=*this;
        while(tmp>=sec)
        {
            tmp=tmp-sec;
        }
        return tmp;
    }
 
    BigInteger& operator++()
    {
        this->plusone();
        return *this;
    }
 
    bool operator<=(const BigInteger& sec)
    {
        if(len<sec.len)
            return true;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]>sec.num[i])
                return false;
        }
        return true;
    }
 
    bool operator>=(const BigInteger& sec)
    {
        if(len>sec.len)
            return true;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]<sec.num[i])
                return false;
        }
        return true;
    }
 
    bool operator==(const BigInteger& sec)
    {
        if(len!=sec.len)
            return false;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]!=sec.num[i])
                return false;
        }
        return true;
    }
 
    bool operator==(const int& sec)
    {
        if(len!=1)
            return false;
        if(num[0]==sec)
            return true;
        else
            return false;
    }
 
    bool operator<(const BigInteger& sec)
    {
        if(len<sec.len)
            return true;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]>sec.num[i])
                return false;
            else if(num[i]<sec.num[i])
                return true;
        }
        return false;
    }
 
    bool operator>(const BigInteger& sec)
    {
        if(len>sec.len)
            return true;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]<sec.num[i])
                return false;
            else if(num[i]>sec.num[i])
                return true;
        }
        return false;
    }
 
    bool operator!=(const BigInteger& sec)
    {
        if(len!=sec.len)
            return true;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i]!=sec.num[i])
                return true;
        }
        return false;
    }
 
    /*BigInteger GCD(const BigInteger& first,const BigInteger& sec)
    {
        return first%sec==0?sec:GCD(sec,first%sec);
    }
 
    BigInteger LCM(const BigInteger& first,const BigInteger& sec)
    {
        return first/GCD(first,sec)*sec;
    }*/
};
#define N 111111
BigInteger dp[111][111];
int main()
{
    BigInteger ZERO("0");
    for(int i=0;i<=110;i++)
    {
        for(int j=0;j<=110;j++)
        {
            dp[i][j]=ZERO;
        }
    }
    dp[2][1]=BigInteger(1);
    dp[2][2]=BigInteger(2);
    for(int i=3;i<=100;i++)
    {
        for(int j=1;j<=i;j++)
        {
            char tmpchar[11];
            sprintf(tmpchar,"%d",j);
             
            /*if(i==7&&j==6)
            {
                cout<<"1::";(BigInteger(tmpchar)*dp[i-1][j]).Print();
                cout<<"2::";(BigInteger(tmpchar)*dp[i-1][j-1]).Print();
                cout<<"dp76::";dp[7][6].Print();
            }*/
             
            dp[i][j]=dp[i][j]+BigInteger(tmpchar)*dp[i-1][j];
            dp[i][j]=dp[i][j]+BigInteger(tmpchar)*dp[i-1][j-1];
             
            /*if(i==7&&j==6)
            {
                cout<<"dp76::";dp[7][6].Print();
            }*/
             
        }
    }
    int ques;
    while(scanf("%d",&ques)!=EOF)
    {
            if(ques==1)
            {
                printf("1\n");
                continue;
            }
            BigInteger ans("0");
            for(int i=1;i<=ques;i++)
            {
                /*if(ques==7)
                {
                    cout<<"ans::";ans.Print();
                    cout<<"dp::"<<"ques::"<<ques<<"i::"<<i<<' ';dp[ques][i].Print();
                }*/
                ans=ans+dp[ques][i];
            }
            ans.Print();
    }
    return 0;
}


【总结】2014新生暑假个人排位赛01,布布扣,bubuko.com

【总结】2014新生暑假个人排位赛01

原文:http://blog.csdn.net/u011775691/article/details/37936539

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!