山东省2012年省赛三道水题

来源:互联网 发布:女装连锁店哪些有淘宝 编辑:程序博客网 时间:2024/04/27 18:37

The Best Seat in ACM Contest

Time Limit: 1000MS Memory limit: 65536K

题目描述

Cainiao is a university student who loves ACM contest very much. It is a festival for him once when he attends ACM Asia Regional Contest because he always can find some famous ACMers there.
Cainiao attended Asia Regional Contest Fuzhou Site on November 20, 2011. After he got seat map, he wanted to know which seat is the best one.
Cainiao have joined so many QQ Group about ACM/ICPC that he is almost familiar with the strength of each team. In his mind, the value of a seat is defined as following:

1. Strength of each team can be expressed as a positive integer.
2. The value of a seat is related to the adjacent seat (up/down/left/right, only four directions being considering).
3. For an adjacent seat, if the strength of this team is stronger than yours, the absolute value of difference of two teams should be added to your seat, otherwise, the absolute value of difference should be subtracted from your seat.
4. If the adjacent seat is empty (which means you are located at the most left/right/up/down), the value of your seat should be subtracted 1.
5. The best one in a contest is the seat that has the highest value.
6. The initial value of the seat is ZERO.

For example, there are 12 ( 3 X 4 ) teams in a contest, the strength of each team is as figure (a), and then you can calculate the value of each seat as figure (b).

 

输入

Input contain a positive integer T( T <=50 ) in the first line, which means T cases.
The first line of each case contains two positive integers N and M (3 <= N, M <= 20) which means the row and column number of the teams, then N rows following, each line contains M positive integers that represent the strengths of the teams.

输出

For each case, first output the case number, and then output the value and row number and column number of the best seat in one line for each case. 
If there are multiple solutions for one case, you should output the seat whose row number is largest and only output the seat whose column number is largest if still overlapping.

示例输入

13 41 5 3 46 3 3 44 3 2 1

示例输出

Case 1: 7 1 1
求绝对值的差值的题目。
#include<iostream>#include<stdio.h>#include<cmath>#define inf 99999999using namespace std;int dir[4][2]= {0,1,0,-1,-1,0,1,0};int map[22][22],tmap[22][22];int n,m;int main(){    int cas;    cin>>cas;    for(int l=1;l<=cas;l++)    {        cin>>n>>m;        for(int i=0; i<n; i++)            for(int j=0; j<m; j++)            {                cin>>map[i][j];                tmap[i][j]=0;            }        for(int i=0; i<n; i++)        {            for(int j=0; j<m; j++)            {                if((i==0&&j==0)||(i==0&&j==m-1)||(i==n-1&&j==0)||(i==n-1&&j==m-1))                    tmap[i][j]-=2;                else if((i==0&&j!=0&&j!=m-1)||(i==n-1&&j!=0&&j!=m-1)||(j==0&&i!=0&&i!=n-1)||(j==m-1&&i!=0&&i!=n-1))                    tmap[i][j]-=1;                for(int k=0; k<4; k++)                {                    int x=i+dir[k][0];                    int y=j+dir[k][1];                    if(x>=0&&x<n&&y>=0&&y<m)                    {                        if(map[i][j]<map[x][y])                            tmap[i][j]+=map[x][y]-map[i][j];                        else                            tmap[i][j]-=map[i][j]-map[x][y];                    }                }            }        }        int max=-inf;        int xx,yy;        for(int i=n-1;i>=0;i--)        {            for(int j=m-1;j>=0;j--)            {                if(tmap[i][j]>max)                {                    max=tmap[i][j];                    xx=i;                    yy=j;                }            }        }       printf("Case %d: %d %d %d\n",l,max,xx+1,yy+1);    }    return 0;}/**************************************Problem id: SDUT OJ C User name: 夕阳 Result: Accepted Take Memory: 1568K Take Time: 0MS Submit Time: 2013-02-24 10:20:49  **************************************/

n a^o7 !

Time Limit: 1000MS Memory limit: 65536K

题目描述

All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my instructions, which can make you in the best state preparing to fight. Now please relax yourself and enjoy the good moment. Before you raise your sharp sword to the enemy who guards the battleground, please allow me to tell you a true and romantic story about a samurai like you. 
Samurai hh fell in love with girl ss, who is charming and demure. He realized the truth that he must spend his remaining life with ss, and resolved to pursue the hard-won affection. One day hh wrote a letter to ss, when she opens the letter with excitement her mind was in tangle. She found herself completely not to figure out the meaning about the letter, which said that "n 55!w ! pue n a^o7 ! n paau !". ss also immersed herself in guessing the meaning of that letter for a long time because of her adore to hh. Finally she called hh to ask the meaning of the letter. On the other side of the phone, hh was too nervous to say. Gradually he calmed down himself and told ss to reverse the letter and read it. Then on both ends of the phone comes the voice at the same time "i need u i love u and i miss u".
ss wants to tell each of you however you are Brave And Skilled, you shouldn't forget to express your loyal love and romantic feelings to your prince or princess.
Now the horn sounds for battle,do it by the following input and output. I think each of you will get an "Accepted" in this battle with pleasant mood.

输入

Input contains an integer T in the first line, and then T lines follow .Each line contains a message (only contain 'n5!wpuea^o7!' and 
' '(space)), the message's length is no more than 100.

输出

Output the case number and the message. (As shown in the sample output)

示例输入

2n 55!w ! pue n a^o7 ! n paau !n5!wpuea^o7

示例输出

Case 1: i need u i love u and i miss u
Case 2: loveandmisu
题意:字符串密码解析题目。反过来看。
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;char str[105];int main(){    int n;    cin>>n;    getchar();    for(int i=1; i<=n; i++)    {        gets(str);        int len=strlen(str);        cout<<"Case "<<i<<": ";        for(int j=len-1; j>=0; j--)        {            if(str[j]=='n')                cout<<"u";            else if(str[j]=='5')                cout<<"s";            else if(str[j]=='!')                cout<<"i";            else if(str[j]=='w')                cout<<"m";            else if(str[j]=='p')                cout<<"d";            else if(str[j]=='u')                cout<<"n";            else if(str[j]=='e')                cout<<"a";            else if(str[j]=='a')                cout<<"e";            else if(str[j]=='^')                cout<<"v";            else if(str[j]=='o')                cout<<"o";            else if(str[j]=='7')                cout<<"l";            else if(str[j]==' ')                cout<<" ";        }        cout<<endl;    }    return 0;}/**************************************Problem id: SDUT OJ G User name: 夕阳 Result: Accepted Take Memory: 1564K Take Time: 0MS Submit Time: 2013-02-24 09:22:33  **************************************/

Pixel density

Time Limit: 1000MS Memory limit: 65536K

题目描述

 

Pixels per inch (PPI) or pixel density is a measurement of the resolution of devices in various contexts; typically computer displays, image scanners, and digital camera image sensors. Note, the unit is not square inches. Good quality photographs usually require 300 pixels per inch when printed. When the PPI is more than 300(phone), we call it retina screen. Sunnypiggy like the retina screen very much.

 


But you know it is expensive for Sunnypiggy and Sunnypiggy’s own smart phone isn’t like that.
I tell you how to calculate the PPI. First we must know how big the mobile phone’s screen is. Then we get the resolution (Hp*Wp) about it. After that we calculate the diagonal resolution in pixels (Dp) and divided by diagonal size in inches. Now you get the answer.
Maybe you knew it, but Sunnypiggy’s math is very bad and he wants you to help him to calculate the pixel density of all the electronic products he dreamed.
 

输入

First you will get an integer T which means the number of test cases, and then Sunnypiggy will tell you the name and type of the electronic products. And you know, Sunnypiggy is a careless boy and some data aren’t standard, just like 04.00 inches or 0800*0480.

输出

Output the answers to Sunnypiggy just like the sample output. Maybe it is not a phone. Sunnypiggy like such a form, although it seems no use. The result should be rounded to 2 decimal places. When it has no screen (0.0 inches) that we define the answer is 0.00(PPI).

示例输入

2iPhone 4S  3.5 inches 960*640 PHONEThe new iPad  0009.7 inches 2048*1536 PAD

示例输出

Case 1: The phone of iPhone 4S's PPI is 329.65.
Case 2: The pad of The new iPad's PPI is 263.92.

题意:字符串里获取数然后计算就行了。此题wa了若干次,PE若干次,坑爹的空格处理,……

 

#include<iostream>#include<stdio.h>#include<string.h>#include<cmath>using namespace std;char str[10005][1005];char s1[1005];int main(){    int cas;    cin>>cas;    getchar();    double wp,hp;    int t=0;    for(int l=1;l<=cas;l++)    {        double dp=0.0;        int k=0;        while(1)        {            cin>>str[k];            if(strcmp(str[k],"inches")==0)            break;            k++;        }        scanf("%lf*%lf",&wp,&hp);        getchar();        gets(s1);        sscanf(str[k-1],"%lf",&dp);        cout<<"Case "<<++t<<": The ";        int len=strlen(s1);        int index;        for(int i=0;i<len;i++)        if(s1[i]!=' ')        {            index=i;            break;        }        for(int i=index;i<len;i++)        {            if(s1[i]>='A'&&s1[i]<='Z')            cout<<char(s1[i]+32);            else            cout<<s1[i];        }        cout<<" of";        for(int i=0;i<k-1;i++)        cout<<" "<<str[i];        cout<<"'s PPI is ";        if(dp==0.0)        cout<<"0.00."<<endl;        else        printf("%.2lf.\n",sqrt(double(wp*wp+hp*hp))/dp);    }    return 0;}

原创粉丝点击