模拟专题(hrbeuOJ)

来源:互联网 发布:fp树关联规则算法 编辑:程序博客网 时间:2024/06/06 10:41

开锁

TimeLimit: 1 Second   MemoryLimit: 64 Megabyte

Totalsubmit: 101   Accepted: 16  

Description

现在xiaoz开学了。他们寝室被一密码锁锁住了。他知道密码(密码为三个数,如36-23-12),同时知道开锁的方法。
其方法:
        1.先指针顺时针转两圈。
             2.指针停到第一个数的位置。
        3. 逆时针转一圈。
        4.继续逆时针转转到指针指向第二个数。
        5.指针又顺时针转到指针指向第三个数。
        6.锁打开。

告诉你指针的初始位置和密码,要求出转多少度才能开锁。

Input

有很多组数据。每组数据含有四个数,分别是n,first,midle,last.均是小于40(n为起始位置),大于0的。当输入是0 0 0 0时,结束

Output

输出degree值(所要转度数)。

Sample Input

0 30 0 30
5 35 5 35
0 20 0 20
7 27 7 27
0 10 0 10
9 19 9 19
0 0 0 0

Sample Output

1350
1350
1620
1620
1890
1890


#include<stdio.h>int main(){    int n1,n2,n3,n4,dig;    while(scanf("%d%d%d%d",&n1,&n2,&n3,&n4)==4&&(n1||n2||n3||n4)){        dig=120;        if(n1<n2)            dig+=40+n1-n2;        else            dig+=n1-n2;        if(n2<n3)            dig+=n3-n2;        else            dig+=40+n3-n2;        if(n3<n4)            dig+=40+n3-n4;        else            dig+=n3-n4;        printf("%d\n",dig*9);    }    return 0;}

猜数

TimeLimit: 1 Second   MemoryLimit: 64 Megabyte

Totalsubmit: 388   Accepted: 52  

Description

Xiaoz提前回到学校。他们寝室只有他和另一个兄弟。我晚上实在是没有事了。于是xiaoz想出来了以个很好的游戏。要他兄弟猜他身上有多少钱。
猜的方法是:
    他兄弟说一个数,由xiaoz判断如果xiaoz认为他没有这么多钱,他会回答too high,如果xiaoz认为比这多的话,他回答too how。如果他认为游戏结束时,他会说right on。
每次游戏结束。由他兄弟判断是不是ziaoz说谎。如是说谎。这输出xiaoz is dishonest,否则输出 xiaoz is honest。

Input

有多组数据,输入一个数整数n(0<=n<=10)。接下来的一行是(too high,too low,right on)中一个。如果是right on,则这组输入结束

Output

Xiaoz没有说谎,则输出”xiaoz may be honest”,否则输出” xiaoz is dishonest”,每组输出占一行。

Sample Input

10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on

Sample Output

xiaoz is dishonest
xiaoz may be honest

#include<stdio.h>int main(){    char s1[10],s2[10];    int n,maxn,minn;    while(scanf("%d",&n)==1){        maxn=11;minn=-1;        while(1){            scanf("%s%s",s1,s2);            if(s2[0]=='h'){                if(maxn>n)                    maxn=n;            }            else if(s2[0]=='l'){                if(minn<n)                    minn=n;            }            else                break;            scanf("%d",&n);        }        if((minn<n)&&(maxn>n))            printf("xiaoz may be honest\n");        else            printf("xiaoz is dishonest\n");    }    return 0;}

欧几里德游戏

TimeLimit: 1 Second   MemoryLimit: 64 Megabyte

Totalsubmit: 64   Accepted: 11  

Description

两个玩家,Stan 和Ollie,玩,开始有两个非负数。Stan为第一个玩家,从大数中减去一个小数的任意倍(这个小数的倍数小于大数),其结果给被减的大数,Then Ollie,第二个玩家,重复第一个玩的玩法,然后循环这样的玩法。直到小数不能在大数中拿到一个非零的数为止。最后一个拿到数的为赢家。

Input

有多组数据。每组数据有两个整数。

Output

I如果是Stan赢了,就输出“Stan win”,否则输出“Ollie win”。

Sample Input

34 12
15 24

Sample Output

Stan wins
Ollie wins

#include<stdio.h>int main(){    int a,b;    int cnt,k;    while(scanf("%d%d",&a,&b)==2&&(a||b)){        cnt=0;        while(a&&b){            if(a>b){                cnt++;                k=a/b;                a%=b;                if(k>=2)                    break;            }            else{                cnt++;                k=b/a;                b%=a;                if(k>=2)                    break;            }        }        if(cnt%2==1)            printf("Stan wins\n");        else            printf("Ollie wins\n");    }    return 0;}

棋盘

TimeLimit: 1 Second   MemoryLimit: 64 Megabyte

Totalsubmit: 6   Accepted: 3  

Description

现有一些关于国际象棋的记录,请输出相应的棋盘“图片”,为了辨别各种棋子,用以下字母标识:K(国王)、Q(王后)、R(车)、B(象)、N(马)、P(卒)。

Input

总共有白方和黑方两方的棋子,第一行为白方的棋子,以“White: ”开始;第二行为黑方的棋子,以“Black: ”开始。其中,每个棋子间用“,”分隔开。每一个棋子的表示方法是:“标识+坐标”,仅有卒在输入时不加标识,坐标使用的是正规国际象棋的坐标。

Output

一个由ASCII字符组成的棋盘,水平边界用“-”,竖直边界用“|”,拐角处用“+”,黑色方格用“:”填充,白色方格用“.”填充,存在棋子的地方用其字母标识表达,另外白方的棋子使用大写字母,黑方的棋子使用小写字母标识。

Sample Input

White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4
Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6

Sample Output

+---+---+---+---+---+---+---+---+
|.r.|:::|.b.|:q:|.k.|:::|.n.|:r:|
+---+---+---+---+---+---+---+---+
|:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.|
+---+---+---+---+---+---+---+---+
|...|:::|.n.|:::|...|:::|...|:p:|
+---+---+---+---+---+---+---+---+
|:::|...|:::|...|:::|...|:::|...|
+---+---+---+---+---+---+---+---+
|...|:::|...|:::|.P.|:::|...|:::|
+---+---+---+---+---+---+---+---+
|:P:|...|:::|...|:::|...|:::|...|
+---+---+---+---+---+---+---+---+
|.P.|:::|.P.|:P:|...|:P:|.P.|:P:|
+---+---+---+---+---+---+---+---+
|:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.|
+---+---+---+---+---+---+---+---+

#include <iostream>#include<cstring>#include<cstdio>using namespace std;char map[10][10];char str[100];char line[40]={"+---+---+---+---+---+---+---+---+"};void process(int flag){    int l=strlen(str);    char chess='P';    int xx,yy;    for(int i=7;i<l;i++){        if(str[i]==',')            continue;        else if(str[i]>96)            yy=105-str[i];        else if(str[i]>64)            chess=str[i];        else{            xx=str[i]-'0';            map[xx][yy]=chess+('a'-'A')*flag;            chess='P';        }    }    return ;}int main(){    memset(map,0,sizeof(map));    gets(str);    process(0);    gets(str);    process(1);    for(int x,i=1;i<=17;i++){        if(i%2==1)            printf("%s\n",line);        else{            for(int y,j=0,x=i/2;j<=32;j++){                y=(j+3)/4;                switch(j%4){                case 0:                    printf("|");break;                case 2:                    if(map[9-x][9-y]!=0)                        printf("%c",map[9-x][9-y]);                    else                        printf("%c",((x+y)%2)?(':'):('.'));                    break;                case 1:                case 3:                    printf("%c",((x+y)%2)?(':'):('.'));                }            }            printf("\n");        }    }    return 0;}


0 0
原创粉丝点击