山东省第三届ACM大学生程序设计竞赛(待添加)

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 uCase 2: loveandmisu                                                                                                 
水!!
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char s[107];
int main()
{
    int t;
    scanf("%d",&t);
    getchar();
    for(int textcase=1;textcase<=t;textcase++)
    {
        gets(s);
        int len=strlen(s);
        printf("Case %d: ",textcase);
        for(int i=len-1;i>=0;i--)
        {
            if(s[i]=='!')printf("i");
            else if(s[i]=='u')printf("n");
            else if(s[i]=='a')printf("e");
            else if(s[i]=='p')printf("d");
            else if(s[i]=='n')printf("u");
            else if(s[i]=='7')printf("l");
            else if(s[i]=='^')printf("v");
            else if(s[i]=='e')printf("a");
            else if(s[i]=='w')printf("m");
            else if(s[i]=='5')printf("s");
            else printf("%c",s[i]);
        }
        printf("\n");
    }
    return 0;
}

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<stdio.h>
#define inf 0x3f3f3f
int s[27][27];
int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int n,m;
int judge(int x,int y)
{
    int count=0;
    for(int i=0;i<4;i++)
    {
        int value=s[x][y];
        int xx=x+dir[i][0];
        int yy=y+dir[i][1];
        if(xx<1||xx>n||yy<1||yy>m){count--;continue;}
        if(s[xx][yy]>=value)count+=(s[xx][yy]-value);
        else count-=(value-s[xx][yy]);
    }
    return count;
}
int main()
{
    int t;
    scanf("%d",&t);
    for(int textcase=1;textcase<=t;textcase++)
    {
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                scanf("%d",&s[i][j]);
        int max=-inf,tmp,x,y;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
            {
                tmp=judge(i,j);
                if(tmp>max){x=i;y=j;max=tmp;}
            }
       printf("Case %d: %d %d %d\n",textcase,max,x,y);

    }
    return 0;
}
  
  

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.


坑点很多

1、小数点可以没有,用小数点和星号做分隔符的可以省省了。

2、空格没说几个,用getline()相当麻烦,不如手动输入字符串数组。

3、inches不是唯一分隔符,手机名称中可能带inches字样,所以应该find_last_of("inches")(我没有用这个方法)

4、注意0.00的结果。

5、手机名称中如果有N个空格 输出的时候输出一个空格。

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#define eps 1e-9
using namespace std;
string str[1007];
int main()
{
    int t,cas=1;
    scanf("%d",&t);
    while(t--)
    {
        //memset(str,0,sizeof(str));
        string w,h;
        int k=0,pos1,pos2,pos3;
        double a,b,z,result;
        char c;
        while(true)
        {
            cin>>str[k++];
            if(str[k-1]=="inches")
            {
                pos1=k-2;
                pos2=k;
            }
            c=getchar();
            if(c=='\n')break;
        }
        z=atof(str[pos1].c_str());
        pos3=str[pos2].find("*");
        for(int i=0;i<pos3;i++)
            h+=str[pos2][i];
        for(int i=pos3+1;i<str[pos2].size();i++)
            w+=str[pos2][i];
        a=atof(w.c_str());
        b=atof(h.c_str());
        //printf("a=%.2lf b=%.2lf\n",a,b);
        if(fabs(z)<=eps)result=0;
        else result=sqrt(a*a+b*b)/z;
        for(int i=pos2+1;i<k;i++)
            for(int j=0;j<str[i].size();j++)
                str[i][j]=tolower(str[i][j]);
        printf("Case %d: The ",cas++);
        for(int i=pos2+1;i<k;i++)
            cout<<str[i]<<" ";
        printf("of");
        for(int i=0;i<pos1;i++)
            cout<<" "<<str[i];
        printf("'s PPI is %.2lf.\n",result);
    }
    return 0;
}


  
  

Pick apples

Time Limit: 1000MS Memory limit: 165536K

题目描述

Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each kind of apple has a size and a price to be sold. Now the little girl wants to gain more profits, but she does not know how. So she asks you for help, and tell she the most profits she can gain.

输入

In the first line there is an integer T (T <= 50), indicates the number of test cases. In each case, there are four lines. In the first three lines, there are two integers S and P in each line, which indicates the size (1 <= S<= 100) and the price (1 <= P <= 10000) of this kind of apple.

In the fourth line there is an integer V,(1 <= V <= 100,000,000)indicates the volume of the girl's bag.

输出

For each case, first output the case number then follow the most profits she can gain.

示例输入

11 12 13 16

示例输出

Case 1: 6

分明是个完全背包,还要把数弄的这么大。所以如果数大于100W的话,就要分两步了,100W以上的用贪心,以下的直接完全背包。

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long a[5],b[5],dp[1000307];
struct sa
{
    int id;
    double c;
}s[5];
int cmp(sa a,sa b)
{
    return a.c>b.c;
}
int main()
{
    int t;
    scanf("%d",&t);
    for(int cas=1;cas<=t;cas++)
    {
        memset(dp,0,sizeof(dp));
        for(long long i=1;i<=3;i++)
        {
            scanf("%lld%lld",&b[i],&a[i]);
            s[i].c=double(a[i])/double(b[i]);
            s[i].id=i;
        }
        long long v;
        scanf("%lld",&v);
        sort(s+1,s+1+3,cmp);
        printf("Case %d: ",cas);
        if(v<=1000000)
        {
            for(long long i=1;i<=v;i++)
                for(long long j=1;j<=3;j++)
                    if(i>=b[j])
                        dp[i]=max(dp[i],dp[i-b[j]]+a[j]);
            printf("%lld\n",dp[v]);
        }
        else
        {
            long long num=(v-1000000)/b[s[1].id];
            long long ans=num*a[s[1].id];
            v=v-num*b[s[1].id];
            for(long long i=1;i<=v;i++)
                for(long long j=1;j<=3;j++)
                    if(i>=b[j])
                        dp[i]=max(dp[i],dp[i-b[j]]+a[j]);
            printf("%lld\n",dp[v]+ans);
        }
    }
    return 0;
}
 

Fruit Ninja II

Time Limit: 5000MS Memory limit: 65536K

题目描述


 

Have you ever played a popular game named "Fruit Ninja"?

Fruit Ninja (known as Fruit Ninja HD on the iPad and Fruit Ninja THD for Nvidia Tegra 2 based Android devices) is a video game developed by Halfbrick. It was released April 21, 2010 for iPod Touch and iPhone devices, July 12, 2010 for the iPad, September 17, 2010 for Android OS devices. Fruit Ninja was well received by critics and consumers. The iOS version sold over 200,000 copies in its first month. By March 2011 total downloads across all platforms exceeded 20 million. It was also named one of Time magazine's 50 Best iPhone Apps of 2011.

 

 

"Swipe your finger across the screen to deliciously slash and splatter fruit like a true ninja warrior. Be careful of bombs - they are explosive to touch and will put a swift end to your juicy adventure!" - As it described on http://www.fruitninja.com/, in Fruit Ninja the player slices fruit with a blade controlled via a touch pad. As the fruit is thrown onto the screen, the player swipes their finger across the screen to create a slicing motion, attempting to slice the fruit in parts. Extra points are awarded for slicing multiple fruits with one swipe, and players can use additional fingers to make multiple slices simultaneously. Players must slice all fruit; if three pieces of fruit are missed the game ends. Bombs are occasionally thrown onto the screen, and will also end the game should the player slice them.

Maybe you are an excellent player of Fruit Ninja, but in this problem we focus on something more mathematically. Consider a certain slicing trace you create on the touch pad, you slice a fruit (an apple or a banana or something else) into two parts at once. Can you figure out the volume of each part?

 

 

Impossible task? Let us do some simplification by define our own Fruit Ninja game.
In our new Fruit Ninja game, only one kind of fruit will be thrown into the air - watermelon. What's more, the shape of every watermelon is a special Ellipsoid (details reachable at http://en.wikipedia.org/wiki/Ellipsoid) that it's polar radius OC is always equals to it's equatorial radius OB. Formally, we can get this kind of solid by revolving a certain ellipse on the x-axis. And the slicing trace the player created (represented as MN in Illustration III) is a line parallel to the x-axis. The slicing motion slice the watermelon into two parts, and the section (shown as the dark part in Illustration III) is parallel to plane x-O-y.

Given the length of OA, OB, OM (
OM is the distance between the section and plane x-O-y), your task is to figure out the volume of the bigger part.


输入

There are multiple test cases. First line is an integer T (T ≈ 100), indicating the number of test cases.

For each test case, there are three integers: a, b, H, corresponding the length of OA, OB, 
OM. You may suppose that 0 < b <= a <= 100 and 0 <= H <= 100.

输出

Output case number "Case %d: " followed by a floating point number (round to 3) for each test case.

示例输入

4
2 2 0
2 2 1
2 2 2
2 2 3

示例输出

Case 1: 16.755
Case 2: 28.274
Case 3: 33.510
Case 4: 33.510


一个椭球物体,用一个平面去截取,求剩下的椭球体最大的体积。
可以三重积分去解决:

#include<stdio.h>
#include<math.h>
#define pi  acos(-1)
int main()
{
    int t,cas=1;
    scanf("%d",&t);
    while(t--)
    {
        double a,b,c;
        scanf("%lf%lf%lf",&a,&b,&c);
        if(c>=b)c=b;
        double v=2.0/3.0*pi*a*b*b+pi*a*b*c-pi*a*c*c*c/(3.0*b);
        printf("Case %d: %.3lf\n",cas++,v);
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值