比赛:ICPC Asia Taipei-Hsinchu Regional 2019 2020.4.1

C. Are They All Integers?

题意:是给定n个数字判断对任意的(a[j]-a[i])/a[k]一定要是整数。

题解:

一开始以为用枚举会超时不过还是试了下,没想到没超时,直接过了,题目很简单,简单枚举就好。

#include<iostream>
using namespace std;
int main(){
    int n,a[1001],sum;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(i!=j&&i!=k&&j!=k){
                    sum=a[i]-a[j];
                    if(sum%a[k]!=0){
                          cout<<"no"<<endl;
                          return 0;
                    }
                }
            }
        }
    }
    cout<<"yes"<<endl;
    return 0;
}

D. Tapioka

题目意思:给3个字符串去掉其中所有的"bubble"和"tapioka"如果没有字符串了就输出nothing(签到题,比较简单)

题解:

根据题意做就好

#include <iostream>
#include<map>
#include<fstream>
using namespace std;
int main()
{
    int n,i,j,k=0;
    map<string,int>h;
    string s[3],a,b,c;
    for(i=0; i<3; i++)
    {
        cin>>s[i];
        if(s[i]=="bubble"||s[i]=="tapioka")
        {
            h[s[i]]=0;
        }
        else
        {
            h[s[i]]=1;
        }
    }
    for(i=0; i<3; i++)
    {
        if(h[s[i]]==1)
        {
            k=1;
            cout<<s[i]<<‘ ‘;
        }
    }
    if(k==0)
    {
        cout<<"nothing";
    }

    return 0;
}

K. Length of Bundle Rope

题目意思:

给定n个盒子用绳子把他们连起来,问最少需要多少的绳子,把多大的盒子连起来绳子大小就加上多少。

题解:

一开始想用dp,发现不用,就是把其中最小的两个盒子加起来,然后再判断,再把其中两个盒子加起来,直到n=2时,进行最后一个相加就好

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t,n,sum;
    int a[1001];
    cin>>t;
    while(t--){
        sum=0;
        cin>>n;
     for(int i=0;i<n;i++){
         cin>>a[i];
     }
     while(n>1){//如果有盒子可以相加,就继续循环
       sort(a,a+n);
       sum=sum+a[0]+a[1];//将2个最小的盒子加起来n该-1
       a[0]=a[0]+a[1];
       for(int i=1;i<n;i++){
           a[i]=a[i+1];
       }
       n--;//加起来后n-1
     }
     cout<<sum<<endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/liyongqi/p/12616903.html

时间: 2024-11-06 07:22:29

比赛:ICPC Asia Taipei-Hsinchu Regional 2019 2020.4.1的相关文章

hdu 5008(2014 ACM/ICPC Asia Regional Xi&#39;an Online ) Boring String Problem(后缀数组&amp;二分)

Boring String Problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 219    Accepted Submission(s): 45 Problem Description In this problem, you are given a string s and q queries. For each que

2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873

Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 439    Accepted Submission(s): 157 Problem Description A mysterious country will hold a football world championships---Abnormal Cup

2014 ACM/ICPC Asia Regional Xi&#39;an Online 233 Matrix,hdu 5015

比赛的时候若是这题过了就进前50 刚开始的时候大家的思路都以为是找规律的题目,于是再推公式,此外还发现类似于杨辉三角.于是又去套杨辉三角的通项去求. 于是TLE了无数次.(每次取范围的最大值也要3s多). 对于明显的矩阵样子,其实可以转化为矩阵的运算,每一行的转移.就是对一个转移矩阵的幂运算.然后再用快速矩阵幂即可. A: 10 0 0 1 10 1 0 1 10 1 1 1 0  0  0 1 B: 23 0 0 3 C=A^M  *B,ans=C[N] 教训:对于时间限制,即便是最大数据也要

HDU 5785 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)

Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 976    Accepted Submission(s): 375 Problem Description The shorter, the simpler. With this problem, you should be convinced of this tru

2014 ACM/ICPC Asia Regional Guangzhou Online Wang Xifeng&#39;s Little Plot HDU5024

一道好枚举+模拟题目.转换思维视角 这道题是我做的,规模不大N<=100,以为正常DFS搜索,于是傻乎乎的写了起来.各种条件限制模拟过程 但仔细一分析发现对每个点进行全部八个方向的遍历100X100X100^8 .100X100个点,每个点在走的时候8中选择,TLE 于是改为另一个角度: 以符合要求的点为拐弯点,朝两个垂直的方向走,求出最远的距离.这样只要对每个点各个方向的长度知道,组合一下对应的就OK. 避免了每个点深搜. PS:搜索的时候x,y写反了,导致构图出现问题,以后用[dy][dx]

HDU 5014 Number Sequence(2014 ACM/ICPC Asia Regional Xi&#39;an Online) 题解

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5014 Number Sequence Problem Description There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● ai ∈ [0,n] ● ai ≠ aj( i ≠ j ) For sequence a and sequ

hdu6206 Apple 2017 ACM/ICPC Asia Regional Qingdao Online

地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6206 题目: Apple Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 530    Accepted Submission(s): 172 Problem Description Apple is Taotao's favouri

2016 ACM/ICPC Asia Regional Shenyang Online 1007/HDU 5898 数位dp

odd-even number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 388    Accepted Submission(s): 212 Problem Description For a number,if the length of continuous odd digits is even and the length

hdu 5868 2016 ACM/ICPC Asia Regional Dalian Online 1001 (burnside引理 polya定理)

Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 208    Accepted Submission(s): 101 Problem Description You may not know this but it's a fact that Xinghai Square is