2013ACM/ICPC亚洲区南京站现场赛——题目重现

GPA

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1206 Accepted Submission(s): 748


Problem Description
In college, a student may take several courses. for each course i, he earns a certain credit (c i), and a mark ranging from A to F, which is comparable to a score (s i), according to the following conversion table
2013ACM/ICPC亚洲区南京站现场赛——题目重现

The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,

An additional treatment is taken for special cases. Some courses are based on “Pass/Not pass” policy, where stude nts earn a mark “P” for “Pass” and a mark “N” for “Not pass”. Such courses are not supposed to be considered in computation. These special courses must be ignored for computing the correct GPA.
Specially, if a student’s credit in GPA computation is 0, his/her GPA will be “0.00”.
 

 

Input
There are several test cases, please process till EOF.
Each test case starts with a line containing one integer N (1 <= N <= 1000), the number of courses. Then follows N lines, each consisting the credit and the mark of one course. Credit is a positive integer and less than 10.
 

 

Output
For each test case, print the GPA (rounded to two decimal places) as the answer.
 

 

Sample Input
5
2 B
3 D-
2 P
1 F
3 A
2
2 P
2 N
6
4 A
3 A
3 A
4 A
3 A
3 A
 

 

Sample Output
2.33
0.00
4.00
 
Hint
For the first test case: GPA =(3.0 * 2 + 1.0 * 3 + 0.0 * 1 + 4.0 * 3)/(2 + 3 + 1 + 3) = 2.33 For the second test case: because credit in GPA computation is 0(P/N in additional treatment), so his/her GPA is “0.00”.
 
 
Source
 
 
题意:就是求加权平均数,N,P不考虑(表示不通过和通过);
 
直接上代码好了;
 
 
 
 
#include<stdio.h>

#include<string.h>

int main()

{

    int n,x,i;

    char a[3];

    while(scanf("%d",&n)!=EOF)

    {

        double gpa=0.00;

        int sum=0;

        for(i=0; i<n; i++)

        {

            scanf("%d%s",&x,a);

            if(a[0]=='P'||a[0]=='N')

                continue;

            else

            {

                sum+=x;

                if(a[0]=='A')

                {

                    if(a[1]=='-')

                        gpa+=3.7*x;

                    else

                        gpa+=4.0*x;

                }

                else if(a[0]=='B')

                {

                    if(a[1]=='-')

                        gpa+=2.7*x;

                    else if(a[1]=='+')

                        gpa+=3.3*x;

                    else

                        gpa+=3.0*x;

                }

                else if(a[0]=='C')

                {

                    if(a[1]=='-')

                        gpa+=1.7*x;

                    else if(a[1]=='+')

                        gpa+=2.3*x;

                    else

                        gpa+=2.0*x;

                }

                else if(a[0]=='D')

                {

                    if(a[1]=='-')

                        gpa+=1.0*x;

                    else

                        gpa+=1.3*x;

                }



            }

        }

        if(gpa==0)

            printf("0.00\n");

        else

        {

            gpa=gpa/sum;

            printf("%.2lf\n",gpa);

        }

    }

    return 0;

}

 

 
 

Poor Warehouse Keeper

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1095 Accepted Submission(s): 314


Problem Description
Jenny is a warehouse keeper. He writes down the entry records everyday. The record is shown on a screen, as follow:
2013ACM/ICPC亚洲区南京站现场赛——题目重现

There are only two buttons on the screen. Pressing the button in the first line once increases the number on the first line by 1. The cost per unit remains untouched. For the screen above, after the button in the first line is pressed, the screen will be:
2013ACM/ICPC亚洲区南京站现场赛——题目重现

The exact total price is 7.5, but on the screen, only the integral part 7 is shown.
Pressing the button in the second line once increases the number on the second line by 1. The number in the first line remains untouched. For the screen above, after the button in the second line is pressed, the screen will be:
2013ACM/ICPC亚洲区南京站现场赛——题目重现

Remember the exact total price is 8.5, but on the screen, only the integral part 8 is shown.
A new record will be like the following:
2013ACM/ICPC亚洲区南京站现场赛——题目重现

At that moment, the total price is exact 1.0.
Jenny expects a final screen in form of:
2013ACM/ICPC亚洲区南京站现场赛——题目重现

Where x and y are previously given.
What’s the minimal number of pressing of buttons Jenny needs to achieve his goal?
 

Input
There are several (about 50, 000) test cases, please process till EOF.
Each test case contains one line with two integers x(1 <= x <= 10) and y(1 <= y <= 10 9) separated by a single space - the expected number shown on the screen in the end.
 

Output
For each test case, print the minimal number of pressing of the buttons, or “-1”(without quotes) if there’s no way to achieve his goal.
 

Sample Input
1 1
3 8
9 31
 

Sample Output
0
5
11
 
 
Hint
For the second test case, one way to achieve is: (1, 1) -> (1, 2) -> (2, 4) -> (2, 5) -> (3, 7.5) -> (3, 8.5)
 
Source
 
 
 
题意:输入2个数,x,y ;一个是数量x,一个是总价y。有两种操作,一种是数量不变,总价+1,变成x,1+y;另一种是数量+1,总价加单价,变成x+1,y+y/x。总价显示的为取整后的整数,小数部分忽略。给定一个目标x,y,初始状态为 1,1,求最少需要多少次可以目标状态,不可以达到的话输出-1.
 
思路:如果数量不变加总价的话,那么单价就会变大,否则的话单价是不变的;那么我们可以用贪心的思想,让单价尽可能的大,但小于(y+1)/x,即单价的上线,使总价不会超过;贪心的策略是,每次尽量加价格,加到能满足条件的最大值,然后加一下数量,这样反复直到到达答案。
 
 
 
#include<cstdio>

#include<cstring>

#include<cmath>

using namespace std;

const double eps = 1e-9;



int main ()

{

    double x,y,kk,tmp;

    int cnt,ans;

    while (scanf("%lf%lf",&x,&y)!=EOF)

    {

        if(x>y)

        {

            printf("-1\n");

            continue;

        }

        kk=(y+1-eps)/x;

        cnt=(int)x-1;

        tmp=1;

        for(int i=1;i<=(int)x;i++)

        {

            double tt=i*kk;

            printf("%lf\t",tt);

            ans=(int)(tt-tmp);

            tmp+=ans;

            printf("%lf\t",tmp);

            tmp=tmp*(i+1)/i;

            cnt+=ans;

            printf("%d\t%d\t%lf\n",ans,cnt,tmp);

        }

        printf("%d\n",cnt);

    }

    return 0;

}

 

Ball

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 687 Accepted Submission(s): 283


Problem Description
Jenny likes balls. He has some balls and he wants to arrange them in a row on the table.
Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, Jenny has R red balls, Y yellow balls and B blue balls. He may put these balls in any order on the table, one after another. Each time Jenny places a new ball on the table, he may insert it somewhere in the middle (or at one end) of the already-placed row of balls.
Additionally, each time Jenny places a ball on the table, he scores some points (possibly zero). The number of points is calculated as follows:
1.For the first ball being placed on the table, he scores 0 point.
2.If he places the ball at one end of the row, the number of points he scores equals to the number of different colors of the already-placed balls (i.e. expect the current one) on the table.
3.If he places the ball between two balls, the number of points he scores equals to the number of different colors of the balls before the currently placed ball, plus the number of different colors of the balls after the current one.
What's the maximal total number of points that Jenny can earn by placing the balls on the table?
 

Input
There are several test cases, please process till EOF.
Each test case contains only one line with 3 integers R, Y and B, separated by single spaces. All numbers in input are non-negative and won't exceed 10 9.
 

Output
For each test case, print the answer in one line.
 

Sample Input
2 2 2
3 3 3
4 4 4
 

Sample Output
15
33
51
 
题意:

每次放入一个球所得到的的分数为x1+x2(x1表示在球左边的球的颜色的个数,x2表示在球右边的球的颜色的个数)

其实如果一个球的数量超过了2,那么剩下的就是一个乘法了。 这个理解很简单,因为超过了2的话,说明最优的方案一定是左右各一个,不然如果都在一边的话就只得1分了。

所以只要列举出少于2个的情况即可!!

 

 

>>题目链接<<

 

#include <stdio.h>

#include <string.h>

__int64 p,ans,cnt;

void judge(int x,int y,int z)

{

        if (x+y+z==0) { ans=0; p=0;}

        if (x+y+z==1) { ans=0; p=1;}

        if (x+y+z==2) { ans=1; p=2;}

        if (x+y+z==3) { ans=3; p=3;}

        if (x+y+z==4) { ans=6; p=4;}

        if (x+y+z==5) { ans=10;p=5;}

        if (x+y+z==6) { ans=15;p=6;}

}

int main()

{

    int a[3],i;



    while(scanf("%I64d%I64d%I64d",&a[0],&a[1],&a[2])!=EOF)

    {

        cnt=0,ans=0;

        for(i=0;i<3;i++)

        {

            if(a[i]>2)

            {

                cnt+=a[i]-2;

                a[i]=2;

            }

        }

        judge(a[0],a[1],a[2]);



        ans+=cnt*p;

        printf("%I64d\n",ans);

    }

    return 0;

}

  

 

  今天没有队友助阵,自己发挥的不是很好,尤其是中间一段时间,自己的心比较烦躁,没有耐心看题,导致题目半天看不懂,然后没有好好找规律,,,,
开学了,心不静啊,我好好努力。。。。这学期课真多,准备软考了!

 
 

你可能感兴趣的:(ICPC)