八月七AK专场(虽然我还是没有AK)

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86574#overview

A - 签到

Description
BUAA-SCSE 新家族又要迎来新的同学了。这次的妹子颇多,足足有n人之多(1<=n<=10^6),她们每个人的学号都是1~2*10^9 内的一个整数。
董适早早地就掌握了她们每个人的学号,并且知道她们之中有一个人去幽会男朋友了!!!!
董适统计了在场所有妹子的学号,他想知道,哪个人没来?
Input
第一行是一个整数n,代表这个大班一共有n只妹纸
以下n行每行一个整数,代表每只妹纸的学号
以下n-1行每行一个整数,代表每只来了的妹纸的学号

Output
输出没来的妹纸的学号。

Sample Input
3
10061061
10061023
10061201

10061061
10061023

Sample Output
10061201

因为数字太大了装不下,把数字分成两段分别存在两个数组里。这也是看了网上其它一些人的题解才想到的。

#include "iostream"
#include "cstdio"
#include "cstring"
using namespace std;

int a[2000000],b[2000000],c[2000000],d[2000000];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {

        memset(a,0,sizeof(a));
        memset(b,0,sizeof(a));
        memset(c,0,sizeof(a));
        memset(d,0,sizeof(a));
        for(int i=0;i<n;i++)
        {
            int id;
            scanf("%d",&id);
            a[i]=id;
            b[id/10000]++;
            c[id%10000]++;
        }

        for(int i=0;i<n-1;i++)
        {
            int id;
            scanf("%d",&id);
            b[id/10000]--;
            c[id%10000]--;

        }
        for(int i=0; i<1000000+5; i++)
        {
            if(b[i])
                printf("%d",i);
            if(c[i])
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

B - ACfun

Description
As a former ACMer, “AC” is a special abbreviated word which can bring much pleasure to me. Sometimes it means everything.
This problem is about “AC”.
One day, I write a long string S on the paper which contains “A” and “C”. Now I want to find a lexicographic minimum string T satisfied that T is distinct with all substring of S.

Input
The first line of input file contains an integer T indicating the number of case.
In each test case:
Input a string S consist of “A” and “C”. The length of S is not large than 100.

Output
For each test case:
You should output the string T meet the condition.

Sample Input
1
ACAC

Sample Output
AA

输出一个字典序最小的且和所给子串都不一样的串。找规律啊找规律。规律就是:计算算给串里a的最大连续个数n 输出n+1个a即可

#include "iostream"
#include "cstdio"
#include "cstring"

using namespace std;

int main()
{
    int ncase;
    while(scanf("%d",&ncase)!=EOF)
    {
        for(int i=1;i<=ncase;i++)
        {
            string s;
            cin>>s;
            long lens=s.length();

            int maxcount=0;
            int count=0;
            for(int j=0;j<=lens-1;j++)
            {
                if(s[j]=='A')
                    count++;
                else
                    count=0;
                if(count>maxcount)
                {
                    maxcount=count;
                }

            }

            for(int j=1;j<=maxcount+1;j++)
            {
                cout<<"A";
            }
            cout<<endl;


        }
    }
    return 0;
}


C - Integer in C++

Description
KIDx: I like Java much more than C++, because I can use BigInteger in Java. :)

However, KIDx has to use C++ language to do a project...

KIDx can only use three integer types in C++:

1) short occupies 2 bytes and allows you to store numbers from -32768 to 32767

2) int occupies 4 bytes and allows you to store numbers from -2147483648 to 2147483647

3) long long occupies 8 bytes and allows you to store numbers from -9223372036854775808 to 9223372036854775807

For all the types given above the boundary values are included in the value range.

From this list, KIDx wants you to choose the smallest type that can store a positive integer n.

Input
There are multiple cases.

Each case contains a positive integer n.

It consists of at least one digit and at most 30 digits.

In addition, it doesn't contain any leading zeros.

Output
For each line, print the first type from the list "short, int, long long", that can store the natural number n.

If no one can store the number, just print "It is too big!".

Sample Input
102
50000

Sample Output
short
int

#include “iostream”
#include “cstdio”
#include “cstring”

using namespace std;

int main()
{
string num;
while(cin>>num)
{

    if(num.length()==5)
    {
        if(strcmp(num.data(),"32767")>0)
        {
            cout<<"int"<<endl;
            continue;
        }
        if(strcmp(num.data(),"32767")<=0)
        {
            cout<<"short"<<endl;
            continue;
        }

    }
    if(num.length()==10)
    {
        if(strcmp(num.data(),"2147483647")>0)
        {
            cout<<"long long"<<endl;
            continue;
        }
        if(strcmp(num.data(),"32767")<=0)
        {
            cout<<"int"<<endl;
            continue;
        }

    }
    if(num.length()==19)
    {
        if(strcmp(num.data(),"9223372036854775807")>0)
        {
            cout<<"It is too big!"<<endl;
            continue;
        }
        if(strcmp(num.data(),"It is too big!")<=0)
        {
            cout<<"long long"<<endl;
            continue;
        }

    }

    if(num.length()>=1&&num.length()<=4)
    {
        cout<<"short"<<endl;
        continue;
    }
    if(num.length()>=6&&num.length()<=9)
    {
        cout<<"int"<<endl;
        continue;
    }
    if(num.length()>=11&&num.length()<=18)
    {
        cout<<"long long"<<endl;
        continue;
    }
    cout<<"It is too big!"<<endl;


}
return 0;

}


E - 看病要排队

Description
看病要排队这个是地球人都知道的常识。 
不过经过细心的0068的观察,他发现了医院里排队还是有讲究的。0068所去的医院有三个医生(汗,这么少)同时看病。而看病的人病情有轻重,所以不能根据简单的先来先服务的原则。所以医院对每种病情规定了10种不同的优先级。级别为10的优先权最高,级别为1的优先权最低。医生在看病时,则会在他的队伍里面选择一个优先权最高的人进行诊治。如果遇到两个优先权一样的病人的话,则选择最早来排队的病人。 

现在就请你帮助医院模拟这个看病过程。

Input
输入数据包含多组测试,请处理到文件结束。 
每组数据第一行有一个正整数N(0<N<2000)表示发生事件的数目。 
接下来有N行分别表示发生的事件。 
一共有两种事件: 
1:"IN A B",表示有一个拥有优先级B的病人要求医生A诊治。(0<A<=3,0<B<=10) 
2:"OUT A",表示医生A进行了一次诊治,诊治完毕后,病人出院。(0<A<=3)

Output
对于每个"OUT A"事件,请在一行里面输出被诊治人的编号ID。如果该事件时无病人需要诊治,则输出"EMPTY"。 
诊治人的编号ID的定义为:在一组测试中,"IN A B"事件发生第K次时,进来的病人ID即为K。从1开始编号。 

Sample Input
7
IN 1 1
IN 1 2
OUT 1
OUT 2
IN 2 1
OUT 2
OUT 1
2
IN 1 1
OUT 1 

Sample Output
2
EMPTY
3
1
1 

  优先队列,第一次用这种神奇的东西。

#include “iostream”
#include “cstdio”
#include “cstring”

using namespace std;

int main()
{
string num;
while(cin>>num)
{

    if(num.length()==5)
    {
        if(strcmp(num.data(),"32767")>0)
        {
            cout<<"int"<<endl;
            continue;
        }
        if(strcmp(num.data(),"32767")<=0)
        {
            cout<<"short"<<endl;
            continue;
        }

    }
    if(num.length()==10)
    {
        if(strcmp(num.data(),"2147483647")>0)
        {
            cout<<"long long"<<endl;
            continue;
        }
        if(strcmp(num.data(),"32767")<=0)
        {
            cout<<"int"<<endl;
            continue;
        }

    }
    if(num.length()==19)
    {
        if(strcmp(num.data(),"9223372036854775807")>0)
        {
            cout<<"It is too big!"<<endl;
            continue;
        }
        if(strcmp(num.data(),"It is too big!")<=0)
        {
            cout<<"long long"<<endl;
            continue;
        }

    }

    if(num.length()>=1&&num.length()<=4)
    {
        cout<<"short"<<endl;
        continue;
    }
    if(num.length()>=6&&num.length()<=9)
    {
        cout<<"int"<<endl;
        continue;
    }
    if(num.length()>=11&&num.length()<=18)
    {
        cout<<"long long"<<endl;
        continue;
    }
    cout<<"It is too big!"<<endl;


}
return 0;

}



F - 哈密顿绕行世界问题

Description
一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 

Input20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. 

Output
输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然后个一个: 后列出经过的城市.参看Sample output 

Sample Input
2 5 20
1 3 12
2 4 10
3 5 8
1 4 6
5 7 19
6 8 17
4 7 9
8 10 16
3 9 11
10 12 15
2 11 13
12 14 20
13 15 18
11 14 16
9 15 17
7 16 18
14 17 19
6 18 20
1 13 19
5
0 

Sample Output
1:  5 1 2 3 4 8 7 17 18 14 15 16 9 10 11 12 13 20 19 6 5
2:  5 1 2 3 4 8 9 10 11 12 13 20 19 18 14 15 16 17 7 6 5
3:  5 1 2 3 10 9 16 17 18 14 15 11 12 13 20 19 6 7 8 4 5
4:  5 1 2 3 10 11 12 13 20 19 6 7 17 18 14 15 16 9 8 4 5
5:  5 1 2 12 11 10 3 4 8 9 16 15 14 13 20 19 18 17 7 6 5
6:  5 1 2 12 11 15 14 13 20 19 18 17 16 9 10 3 4 8 7 6 5
7:  5 1 2 12 11 15 16 9 10 3 4 8 7 17 18 14 13 20 19 6 5
8:  5 1 2 12 11 15 16 17 18 14 13 20 19 6 7 8 9 10 3 4 5
9:  5 1 2 12 13 20 19 6 7 8 9 16 17 18 14 15 11 10 3 4 5
10:  5 1 2 12 13 20 19 18 14 15 11 10 3 4 8 9 16 17 7 6 5
11:  5 1 20 13 12 2 3 4 8 7 17 16 9 10 11 15 14 18 19 6 5
12:  5 1 20 13 12 2 3 10 11 15 14 18 19 6 7 17 16 9 8 4 5
13:  5 1 20 13 14 15 11 12 2 3 10 9 16 17 18 19 6 7 8 4 5
14:  5 1 20 13 14 15 16 9 10 11 12 2 3 4 8 7 17 18 19 6 5
15:  5 1 20 13 14 15 16 17 18 19 6 7 8 9 10 11 12 2 3 4 5
16:  5 1 20 13 14 18 19 6 7 17 16 15 11 12 2 3 10 9 8 4 5
17:  5 1 20 19 6 7 8 9 10 11 15 16 17 18 14 13 12 2 3 4 5
18:  5 1 20 19 6 7 17 18 14 13 12 2 3 10 11 15 16 9 8 4 5
19:  5 1 20 19 18 14 13 12 2 3 4 8 9 10 11 15 16 17 7 6 5
20:  5 1 20 19 18 17 16 9 10 11 15 14 13 12 2 3 4 8 7 6 5
21:  5 4 3 2 1 20 13 12 11 10 9 8 7 17 16 15 14 18 19 6 5
22:  5 4 3 2 1 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5
23:  5 4 3 2 12 11 10 9 8 7 6 19 18 17 16 15 14 13 20 1 5
24:  5 4 3 2 12 13 14 18 17 16 15 11 10 9 8 7 6 19 20 1 5
25:  5 4 3 10 9 8 7 6 19 20 13 14 18 17 16 15 11 12 2 1 5
26:  5 4 3 10 9 8 7 17 16 15 11 12 2 1 20 13 14 18 19 6 5
27:  5 4 3 10 11 12 2 1 20 13 14 15 16 9 8 7 17 18 19 6 5
28:  5 4 3 10 11 15 14 13 12 2 1 20 19 18 17 16 9 8 7 6 5
29:  5 4 3 10 11 15 14 18 17 16 9 8 7 6 19 20 13 12 2 1 5
30:  5 4 3 10 11 15 16 9 8 7 17 18 14 13 12 2 1 20 19 6 5
31:  5 4 8 7 6 19 18 17 16 9 10 3 2 12 11 15 14 13 20 1 5
32:  5 4 8 7 6 19 20 13 12 11 15 14 18 17 16 9 10 3 2 1 5
33:  5 4 8 7 17 16 9 10 3 2 1 20 13 12 11 15 14 18 19 6 5
34:  5 4 8 7 17 18 14 13 12 11 15 16 9 10 3 2 1 20 19 6 5
35:  5 4 8 9 10 3 2 1 20 19 18 14 13 12 11 15 16 17 7 6 5
36:  5 4 8 9 10 3 2 12 11 15 16 17 7 6 19 18 14 13 20 1 5
37:  5 4 8 9 16 15 11 10 3 2 12 13 14 18 17 7 6 19 20 1 5
38:  5 4 8 9 16 15 14 13 12 11 10 3 2 1 20 19 18 17 7 6 5
39:  5 4 8 9 16 15 14 18 17 7 6 19 20 13 12 11 10 3 2 1 5
40:  5 4 8 9 16 17 7 6 19 18 14 15 11 10 3 2 12 13 20 1 5
41:  5 6 7 8 4 3 2 12 13 14 15 11 10 9 16 17 18 19 20 1 5
42:  5 6 7 8 4 3 10 9 16 17 18 19 20 13 14 15 11 12 2 1 5
43:  5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5
44:  5 6 7 8 9 16 17 18 19 20 1 2 12 13 14 15 11 10 3 4 5
45:  5 6 7 17 16 9 8 4 3 10 11 15 14 18 19 20 13 12 2 1 5
46:  5 6 7 17 16 15 11 10 9 8 4 3 2 12 13 14 18 19 20 1 5
47:  5 6 7 17 16 15 11 12 13 14 18 19 20 1 2 3 10 9 8 4 5
48:  5 6 7 17 16 15 14 18 19 20 13 12 11 10 9 8 4 3 2 1 5
49:  5 6 7 17 18 19 20 1 2 3 10 11 12 13 14 15 16 9 8 4 5
50:  5 6 7 17 18 19 20 13 14 15 16 9 8 4 3 10 11 12 2 1 5
51:  5 6 19 18 14 13 20 1 2 12 11 15 16 17 7 8 9 10 3 4 5
52:  5 6 19 18 14 15 11 10 9 16 17 7 8 4 3 2 12 13 20 1 5
53:  5 6 19 18 14 15 11 12 13 20 1 2 3 10 9 16 17 7 8 4 5
54:  5 6 19 18 14 15 16 17 7 8 9 10 11 12 13 20 1 2 3 4 5
55:  5 6 19 18 17 7 8 4 3 2 12 11 10 9 16 15 14 13 20 1 5
56:  5 6 19 18 17 7 8 9 16 15 14 13 20 1 2 12 11 10 3 4 5
57:  5 6 19 20 1 2 3 10 9 16 15 11 12 13 14 18 17 7 8 4 5
58:  5 6 19 20 1 2 12 13 14 18 17 7 8 9 16 15 11 10 3 4 5
59:  5 6 19 20 13 12 11 10 9 16 15 14 18 17 7 8 4 3 2 1 5
60:  5 6 19 20 13 14 18 17 7 8 4 3 10 9 16 15 11 12 2 1 5 

  dfs有几天没做了结果就有点忘了。。看了这个:http://blog.csdn.net/wchyumo2009/article/details/7384695 对着差不多的敲了一遍

#include

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值