2020.4.6 UCF Local Programming Contest 2017 比赛报告

A. Electric Bill

就是一算阶梯电费的题(大概),该咋算咋算就好

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,n;
    cin>>a>>b>>n;
    int am[n],cost[n];
    int i;
    for(i = 0;i < n;i++)
    {
        cin>>am[i];
    }
    for(i = 0;i < n;i++)
    {
        if(am[i]<=1000)
        {
            cost[i] = a*am[i];
        }
        else
        {
            cost[i] = 1000*a+(am[i]-1000)*b;
        }
    }
    for(i = 0;i < n;i++)
    {
        cout<<am[i]<<" "<<cost[i]<<endl;
    }
}

B. Simplified Keyboard

简单讲,就是说给你两个字符串,之后这俩字符串有三种情况,一种是完全相同,一种是相似,就是长度相同,字母不同,但每一位的字母是相邻关系(相邻关系表见题目),第三种就是除了以上两种之外的,算不同,题目问判断输入的两组字符串符合上面说的哪种情况

(代码队友写的,有些过于诡异,大概的意思就是和搜索差不多)

代码:

#include<bits/stdc++.h>
using namespace std;
int pos[9] = {-10,-9,-8,-1,0,1,8,9,10};
char a[27] = "abcdefghijklmnopqrstuvwxyz";
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int i,j,k;
        int flag = 3;
        char s1[21],s2[21];
        scanf("%s %s",s1,s2);
        if(strcmp(s1,s2)==0)
            flag=1;
        else
        {
            if(strlen(s1)!=strlen(s2))
                flag = 3;
            else
            {

                flag = 2;
                for(i = 0; i < strlen(s1); i++)
                {
                    int isok = 0;
                    for(j = 0; j < 9; j++)
                    {
                        if(s2[i]-'a'+pos[j]>=0&&s2[i]-'a'+pos[j]<=25)
                        {
                            if(s1[i]==a[s2[i]-'a'+pos[j]])
                            {
                                isok = 1;
                                break;
                            }


                        }

                    }if(isok == 1)
                            continue;
                            else {flag = 3;break;}

                }

            }
        }
        cout<<flag<<endl;
    }



}

C. Singin' in the Rain

c我是真的没读也没写,队友大佬代码贴上

代码:

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int m,n,t,s;
    long long int sum=0;
    int a[1010];
    scanf("%d",&n);
    while(n--){
        sum=0;
        scanf("%d %d",&t,&s);
        for(int i=0;i<s;i++){
            scanf("%d",&a[i]);
        }
        for(int i=0;i<s-1;i++){
            if(a[i]>a[i+1]){
                sum+=min((a[i]-a[i+1]+1),(a[i+1]+t-1-a[i]));
            }else if(a[i]==a[i+1]){
                sum++;
            }else if(a[i]+1==a[i+1]){
                continue;
            }else{
                sum+=min((a[i+1]-a[i]-1),(a[i]+t-a[i+1]+1));
            }
        }
        printf("%lld\n",sum);
    }
}

E. Simple Darts

这个题比较有趣哈,就是说一个简化的飞镖盘(如题目图2),可以分为m份,每份从x正轴开始赋初始分为1,逆时针以此类推加1到w,之后同心圆分三份,最外圈就是初始分,中间圈是初始分*2,靶心是50好像是定的,之后,给你提供飞镖落点的坐标和飞镖数,求总得分

这个首先要判断飞镖落下的分段,也就是靶心、中间、外圈,之后根据角度判断具体分数,用到了反三角函数求弧度,,,嘛,,写起来听麻烦的,,

代码:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<queue>
#define LL long long
const double pi=3.1415926;
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        int w,b,d,s;
        cin >> w >> b >> d >> s;
        int t;
        cin >> t;
        long long int ans = 0;
        while(t--){
            double x,y;
            cin >> x >> y;
            double r,jiao;
            r = x*x + y*y;
            double fen = 2*pi/w;
            if(r < b*b){
                ans+=50;
            }else if(r > b*b && r < d*d){
                if((y/x)>0&&y>0){
                    jiao=atan(y/x);
                }else if((y/x)>0&&y<0){
                    jiao=atan(y/x)+pi;
                }else if((y/x)<0&&y<0){
                    jiao=atan(y/x)+2*pi;
                }else if((y/x)<0&&x<0){
                    jiao=atan(y/x)+pi;
                }else if(x==0&&y>0){
                    jiao=pi/2;
                }else if(x==0&&y<0){
                    jiao=(pi*3)/2;
                }else if(y==0&&x<0){
                    jiao=pi;
                }else if(y==0&&x>0){
                    jiao=0;
                }
                int j=jiao/fen;
                ans+=((j+1)*2);
            }else if(r > d*d && r < s*s){
              if((y/x)>0&&y>0){
                    jiao=atan(y/x);
                }else if((y/x)>0&&y<0){
                    jiao=atan(y/x)+pi;
                }else if((y/x)<0&&y<0){
                    jiao=atan(y/x)+2*pi;
                }else if((y/x)<0&&x<0){
                    jiao=atan(y/x)+pi;
                }else if(x==0&&y>0){
                    jiao=pi/2;
                }else if(x==0&&y<0){
                    jiao=(pi*3)/2;
                }else if(y==0&&x<0){
                    jiao=pi;
                }else if(y==0&&x>0){
                    jiao=0;
                }
                int j=jiao/fen;
                ans+=(j+1);
            }else{
                ans += 0;
            }
        }
        printf("%lld\n",ans);
    }
}

猜你喜欢

转载自www.cnblogs.com/CCCCrack/p/12653808.html