• UCF Local Programming Contest 2013(Practice)


    # A. The Suffix Game

    # 题意

    # 题解

     1 //A
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 void solve(int r){
     5     string str1,str2;
     6     cin>>str1>>str2;
     7     cout<<"Game #"<<r<<":"<<endl;
     8     cout<<"   "<<"The input words are "<<str1<<" and "<<str2<<"."<<endl;
     9     reverse(str1.begin(),str1.end());
    10     reverse(str2.begin(),str2.end());
    11     string res1,res2;
    12     for(int i=0,j=0;i<str1.size()&&j<str2.size();i++,j++){
    13         if(str1[i] != str2[j] || i==str1.size()-1 || j==str2.size()-1){
    14             res1=str1.substr(i,str1.size());
    15             res2=str2.substr(j,str2.size());
    16             break;
    17         }
    18     }
    19     reverse(res1.begin(),res1.end());
    20     reverse(res2.begin(),res2.end());
    21     cout<<"   The words entered in the notebook are "<<res1<<" and "<<res2<<"."<<endl;
    22     cout<<endl;
    23 }
    24 int main(){
    25     int t;
    26     cin>>t;
    27     for(int i=1;i<=t;i++){
    28         solve(i);
    29     }
    30 }

    # B

    # 题意

    # 题解

     1 // B
     2 #include<bits/stdc++.h>
     3 #define pdd pair<double,double>
     4 #define db double
     5 #define x first
     6 #define y second
     7 using namespace std;
     8 const int N=55;
     9 pdd a[N];
    10 void solve(int r){
    11     cout<<"Test case #"<<r<<":"<<" ";
    12     int res=0;
    13     int n;
    14     cin>>n;
    15     for(int i=0;i<n;i++)
    16         cin>>a[i].x>>a[i].y;
    17     unordered_map<string,bool>rec;
    18     for(int i=0;i<n;i++)
    19         for(int j=0;j<i && j!=i;j++)
    20             for(int k=0;k<j && k!=i && k!=j;k++){
    21                     db x1 = a[i].x, y1 = a[i].y;
    22                     db x2 = a[j].x, y2 = a[j].y;
    23                     db x3 = a[k].x, y3 = a[k].y;
    24                     db d12 = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    25                     db d13 = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
    26                     db d23 = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
    27                     db s=(d12+d23+d13)/2;
    28                     db delta = (s-d12)*(s-d13)*(s-d23);
    29                     db jud=fabs(x1*y2+y1*x3+x2*y3-y2*x3-y3*x1-y1*x2)/2;
    30                     if(delta <=0 || jud==0)
    31                         continue;
    32                     else {
    33                         res++;
    34                     }
    35                 }
    36 
    37     cout<<res<<" "<<"triangle(s) can be formed."<<endl;
    38     cout<<endl;
    39 }
    40 int main(){
    41     ios::sync_with_stdio(0);
    42     cin.tie(0);
    43     cout.tie(0);
    44     int t;
    45     cin>>t;
    46     for(int i=1;i<=t;i++){
    47         solve(i);
    48     }
    49 }

    # C

    # 题意

    # 题解

     1 //C
     2 #include<bits/stdc++.h>
     3 #define pdd pair<double,double>
     4 #define db double
     5 #define fi first
     6 #define se second
     7 using namespace std;
     8 const int N=55;
     9 pdd a[N];
    10 unordered_map<int,string>u;
    11 
    12 void solve(int r){
    13     string a;
    14     unordered_map<char,int>p;
    15     cin>>a;
    16     cout<<"UCF Hold-em #"<<r<<": "<<a<<endl;
    17     for(int i=0;i<a.size();i++){
    18         p[a[i]]++;
    19     }
    20     int res;
    21     bool flag=0;
    22     while(!flag){
    23     for(auto x:p){
    24         if(x.se == 4) {
    25             res=5;
    26             flag=1;
    27         }
    28     }
    29     if(flag)break;
    30     bool cnt1=0,cnt2=0;
    31     for(auto x:p){
    32         if(x.se>=3) {
    33             cnt1=1;
    34             continue;
    35         }
    36         if(x.se>=2){
    37             cnt2=1;
    38             continue;
    39         }
    40     }
    41     if(cnt1 && cnt2){
    42         flag=1;
    43         res=4;
    44     }
    45     if(flag)break;
    46     for(auto x:p){
    47         if(x.se == 3) {
    48                 res=3;
    49                 flag=1;
    50             }
    51         }
    52     if(flag)break;
    53         for(auto x:p){
    54             if(x.se == 2) {
    55                 res=2;
    56                 flag=1;
    57             }
    58         }
    59         if(flag)break;
    60     res=1;
    61     break;
    62     }
    63     cout<<"Best possible hand: "<<u[res]<<endl<<endl;
    64 }
    65 int main(){
    66     ios::sync_with_stdio(0);
    67     cin.tie(0);
    68     cout.tie(0);
    69     int t;
    70     cin>>t;
    71     u[5]="FOUR OF A KIND";
    72     u[4]="FULL HOUSE";
    73     u[3]="THREE OF A KIND";
    74     u[2]="TWO OF A KIND";
    75     u[1]="BUST";
    76     for(int i=1;i<=t;i++){
    77         solve(i);
    78     }
    79 }

    # D

    # 题意

    # 题解

    # E

    # 题意

    # 题解

     1 #include<bits/stdc++.h>
     2 #define pdd pair<double,double>
     3 #define db double
     4 #define fi first
     5 #define se second
     6 using namespace std;
     7 const int N=1e3+5;
     8 char s[5][N];
     9 void work(int a,int &b,int &c){
    10     for(b=a+1;b<=500;b++)
    11         for(c=b+1;c<=500;c++){
    12             int b_=b,c_=c;
    13             bool flag=1;
    14             for(int i=3;i>=1;i--,b_/=10,c_/=10){
    15                 int x=b_%10;
    16                 int y=c_%10;
    17                 if(s[2][i]!='-' && (s[2][i]-'0')!=x) flag=0;
    18                 if(s[3][i]!='-' && (s[3][i]-'0')!=y) flag=0;
    19             }
    20             if(flag) return;
    21         }
    22 }
    23 
    24 int main(){
    25     ios::sync_with_stdio(0);
    26     cin.tie(0);
    27     cout.tie(0);
    28     int t;
    29     scanf("%d",&t);
    30     for(int i=1;i<=t;i++){
    31         for(int i=1;i<=3;i++)
    32             scanf("%s",s[i]+1);
    33         printf("Gas Station #%d:
    ",i);
    34         printf("   Input:  %s %s %s
    ",s[1]+1,s[2]+1,s[3]+1);
    35         char *s1=s[1];
    36         if(s1[1]=='-') s1[1]='2';
    37         if(s1[2]=='-') s1[2]='0';
    38         if(s1[3]=='-') s1[3]='0';
    39         int a=0;
    40         for(int i=1;i<=3;i++)
    41             a=a*10+s1[i]-'0';
    42         int b,c;
    43         work(a,b,c);
    44         printf("   Output: %d %d %d
    
    ",a,b,c);
    45     }
    46 }

    # F

    # 题意

    # 题解

    # G

    # 题意

    # 题解

    # H

    # 题意

    # 题解

    # I

    # 题意

    # 题解

     1 #include<queue>
     2 #include<cassert>
     3 #include<cstdio>
     4 #include<cstring>
     5 #include<cstdlib>
     6 #include<iostream>
     7 #include<algorithm>
     8 #include<unordered_map>
     9 #define fi first
    10 #define se second
    11 
    12 using namespace std;
    13 
    14 typedef long long ll;
    15 typedef pair<int,int>pii;
    16 
    17 const int mod=1e9+7;
    18 const int inf=0x3f3f3f3f;
    19 const int N=1e6+5;
    20 
    21 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    22 ll qmi(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
    23 
    24 pii a[N];
    25 
    26 bool check(pii a,pii b,pii c){
    27     int x1=b.fi-a.fi,x2=c.fi-a.fi;
    28     int y1=b.se-a.se,y2=c.se-a.se;
    29     if(x1*y2==x2*y1) return false;
    30     return true;
    31 }
    32 
    33 int main(){
    34     // freopen("in","r",stdin);
    35     int CASE=0;
    36     int _;for(scanf("%d",&_);_;_--){
    37         int n;scanf("%d",&n);
    38         for(int i=1;i<=n;i++) scanf("%d%d",&a[i].fi,&a[i].se);
    39         int ans=0;
    40         for(int i=1;i<=n;i++)
    41             for(int j=i+1;j<=n;j++)
    42                 for(int k=j+1;k<=n;k++)
    43                     ans+=check(a[i],a[j],a[k]);
    44         printf("Test case #%d: %d triangle(s) can be formed.
    
    ",++CASE,ans);
    45     }
    46     return 0;
    47 }
  • 相关阅读:
    MySQL 对于千万级的大表要怎么优化?
    随便写的一些docker使用操作命令
    零基础学python大概要多久?我用了30天
    普通人学python有意义吗?意义重大
    华为私有云组件
    Mysql 调优(二)分析思路
    MySQL 调优(一)调优原则
    shell脚本获取当前时间,分钟之前时间、小时之前时间和天之前时间
    java_windows环境变量自动设置脚本
    plsql中文乱码问题解决方案
  • 原文地址:https://www.cnblogs.com/hhyx/p/12466142.html
Copyright © 2020-2023  润新知