The 2016 ACM-ICPC Asia Qingdao 重现赛---题解

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37868325/article/details/82944667

A - Relic Discovery

 题意:

Recently, paleoanthropologists have found historical remains on an island in the Atlantic Ocean. The most inspiring thing is that they excavated in a magnificent cave and found that it was a huge tomb. Inside the construction,researchers identified a large number of skeletons, and funeral objects including stone axe, livestock bones and murals. Now, all items have been sorted, and they can be divided into N types. After they were checked attentively, you are told that there are Ai items of the i-th type. Further more, each item of the i-th type requires Bi million dollars for transportation, analysis, and preservation averagely. As your job, you need to calculate the total expenditure.

Input

The first line of input contains an integer T which is the number of test cases. For each test case, the first line contains an integer N which is the number of types. In the next N lines, the i-th line contains two numbers Ai and Bi as described above. All numbers are positive integers and less than 101.

Output

For each case, output one integer, the total expenditure in million dollars, on a line by itself.

思路:水题,乘积和

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        ll n,a,b,ans=0;
        scanf("%lld",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld%lld",&a,&b);
            ans+=a*b;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

B - Pocket Cube

 题意:

The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube. The cube consists of 8 pieces, all corners. Each piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer. For each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise. You should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers.

Input

The first line of input contains one integer N (N ≤ 30) which is the number of test cases. For each test case, the first line describes the top face of the pocket cube, which is the common 2×2 face of pieces labelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces. The second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers aregiven corresponding to the above pieces. The third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0), (0, 0, 0),(0, 1, 0). Four integers are given corresponding to the above pieces. The fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers are given corresponding to the above pieces. The fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are given corresponding to the above pieces. The six line describes the right face, the common face of (0, 1, 1),(0, 1, 0), (1, 1, 1),(1, 1, 0). Four integers are given corresponding to the above pieces. In other words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface development as follows. 

Output

For each test case, output ‘YES’ if can be restored in one step, otherwise output ‘NO’

思路:超级无敌大模拟!自己做个正方体,每个面上标上号,一共六种旋转方案,其中顺逆时针旋转一一对应,所以可以分三种转面情况分析。。没啥东西,就是恶心人!

代码:

#include <bits/stdc++.h>
using namespace std;
int N,T,x,a[30];
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        x=0;
        for(int i=1;i<=24;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<=24;i+=4)
        {
            if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
                continue;
                x=1;break;
        }
        if(!x) {printf("YES\n");continue;}
        int i=5;
        if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
        {
            i=13;
            if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
            {
                if(a[3]==a[4]&&a[23]==a[24]&&a[9]==a[10]&&a[19]==a[20])
                {
                    if(a[1]==a[2]&&a[21]==a[22]&&a[11]==a[12]&&a[17]==a[18])
                    {
                        if(a[1]==a[23]&&a[21]==a[9]&&a[12]==a[19]&&a[17]==a[3])
                            x=0;
                        else if(a[1]==a[19]&&a[17]==a[9]&&a[12]==a[23]&&a[21]==a[3])
                            x=0;
                    }
                }
            }
        }
        i=1;
        if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
        {
            i=9;
            if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
            {
                if(a[5]==a[6]&&a[18]==a[20]&&a[15]==a[16]&&a[21]==a[23])
                {
                    if(a[22]==a[24]&&a[7]==a[8]&&a[17]==a[19]&&a[13]==a[14])
                    {
                        if(a[13]==a[23]&&a[22]==a[6]&&a[7]==a[20]&&a[17]==a[15])
                            x=0;
                        else if(a[17]==a[5]&&a[7]==a[21]&&a[22]==a[15]&&a[13]==a[20])
                            x=0;
                    }
                }
            }
        }
        i=17;
        if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
        {
            i=21;
            if(a[i]==a[i+1]&&a[i]==a[i+2]&&a[i]==a[i+3])
            {
                if(a[5]==a[7]&&a[1]==a[3]&&a[15]==a[13]&&a[9]==a[11])
                {
                    if(a[10]==a[12]&&a[6]==a[8]&&a[2]==a[4]&&a[16]==a[14])
                    {
                        if(a[13]==a[10]&&a[9]==a[6]&&a[7]==a[2]&&a[1]==a[14])
                            x=0;
                        else if(a[1]==a[6]&&a[7]==a[10]&&a[9]==a[16]&&a[13]==a[2])
                            x=0;
                    }
                }
            }
        }
        if(!x) printf("YES\n");
        else printf("NO\n");
    }
}

C - Pocky

题意:

Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length L. While the length of remaining pocky is longer than d, we perform the following procedure. We break the pocky at any point on it in an equal possibility and this will divide the remaining pocky into two parts. Take the left part and eat it. When it is not longer than d, we do not repeat this procedure. Now we want to know the expected number of times we should repeat the procedure above. Round it to 6 decimal places behind the decimal point.

Input

The first line of input contains an integer N which is the number of test cases. Each of the N lines contains two float-numbers L and d respectively with at most 5 decimal places behind the decimal point where 1 ≤ d, L ≤ 150. Output For each test case,

output

the expected number of times rounded to 6 decimal places behind the decimal point in a line.

思路:

重现赛跟着节奏走,这个题都会!而且1A率很高!但是我们又不会!然后看了题解。。。大佬们都直接能看样例推出了公式,,,赛场上正解什么的,几乎不存在。。。猜测解题大法真是优秀、

正解可见此:http://www.zzqq.org/p/33c860e5c5c6299d3e99446f6ff689b0.html

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=0.0000000001;
const int MAXN=10000000;

double L,d;

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        cin>>L>>d;
        if(L<=d)
        {
            printf("0.000000\n");
            continue;
        }
        cout<<fixed<<setprecision(6)<<log(L/d)+1<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37868325/article/details/82944667