2019CCPC-江西省赛(重现赛)

1001

1002

1003

1004

1005

1006

1007 Traffic (HDOJ 6573)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6573

思路:枚举i和j,b[j]+x=a[i]是不可以的情况,标记此刻的x不可取,最后遍历看x能取的最小值

代码:

#include <bits/stdc++.h>

using namespace std;
const int maxn=1e5+10;
int n,m;
int a[maxn],b[maxn],cnt[maxn];

int main(){
    while(~scanf("%d%d",&n,&m)){
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&b[i]);
        }
        memset(cnt,0,sizeof(cnt));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i]-b[j]<0) continue;
                cnt[a[i]-b[j]]++;
            }
        }
        for(int i=0;i<=maxn;i++){
            if(cnt[i]==0){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
} 



1008 Rng (HDOJ 6574)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6574

思路:打表

代码:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll n;

ll quickpow(ll a,ll b){
    if(b<0) return 0;
    ll ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(ret*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ret;
}

ll inv(ll a){
    return quickpow(a,mod-2);
}

int main(){
    scanf("%lld",&n);
    ll ans=((n+1)*inv(2*n))%mod;
    printf("%lld\n",ans);
    return 0;
} 



1009 Budget (HDOJ 6575)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6575

题意:给出1e18范围内的小数,已经四舍五入到三位小数,求四舍五入到两位小数时失去的精度和

思路:因为范围过大,直接乘1000会爆,用字符串读入,只保留小数点后的。

代码:

#include <bits/stdc++.h>

using namespace std;
int n;
char s[55];

int main(){
    while(~scanf("%d",&n)){
        int ans=0;
        while(n--){
            scanf("%s",s);
            int len=strlen(s);
            int flag=0;
            for(int i=0;i<len;i++){
                if(s[i]==‘.‘){
                    flag=i;
                    break;
                }
            }
            int ss=0;
            for(int i=flag+1;i<len;i++){
                ss=ss*10+s[i]-‘0‘;
            }
            if(ss>=995) ans+=1000-ss;
            else{
                int tmp=ss%10;
                if(tmp>=5) ans+=10-tmp;
                else ans-=tmp;
            }
        }
        printf("%.3f\n",(double)ans/1000.0);
    }
    return 0;
}



1010 Worker (HDOJ 6576)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6576

题意:给出n个工厂m个工人,每个工厂中每个人的产出为ai,要求每个工厂的总产出都相等,求问分配工人的方案

思路:要使得每个工厂的总产出相等,相当于求每个工厂单人产出的最小公倍数,求出为了达到最小公倍数每个工厂最少要安排多少人k,判断总工人数是否是k的倍数。m的范围不是1018而是1e18

代码:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn=2020;
int n;
ll a[maxn],b[maxn],m;
int cnt[15];

int main(){
    while(~scanf("%d%lld",&n,&m)){
        memset(cnt,0,sizeof(cnt));
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
            cnt[a[i]]=1;
        }
        int flag,tmp;
        ll sum;
        for(int i=1;i<=10;i++){
            if(cnt[i]!=0){
                flag=i;
                sum=i;
                break;
            }
        }
        tmp=flag;
        for(int i=flag+1;i<=10;i++){
            if(cnt[i]==0) continue;
            tmp=__gcd(sum,(ll)i);
            sum=sum*i/tmp;
        }
    //    cout<<sum<<endl;
        ll kk=0;
        for(int i=1;i<=n;i++){
            b[i]=sum/a[i];
            kk+=b[i];
        }
        if(m%kk==0){
            ll tot=m/kk;
            printf("Yes\n");
            for(int i=1;i<n;i++){
                printf("%lld ",b[i]*tot);
            }
            printf("%lld\n",b[n]*tot);
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}



1011 Class  (HDOJ 6577)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6577

代码:

#include <bits/stdc++.h>

using namespace std;
int x,y;

int main(){
    scanf("%d%d",&x,&y);
    int a=(x+y)/2,b=(x-y)/2;
    printf("%d\n",a*b);
    return 0;
}

原文地址:https://www.cnblogs.com/whdsunny/p/11232588.html

时间: 2024-07-30 07:22:32

2019CCPC-江西省赛(重现赛)的相关文章

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 A Fruit Ninja

传送门 题解:给你一堆点问你能不能找出一条直线,使其穿过的点大于n*x. 题解:想起某道CF题目,给你一堆点问你能不能找出两条直线使其穿过所有的点.当时就是在一定时限内随机找了两个点,再枚举每个点是否满足,如果超过该时限仍然不满足则直接返回no.这题也是一样的做法,直接随机两个点,再枚举过去.因为x为0.1到0.9,所以如果所给数据满足条件,那么它有极大概率能够跑出结果.4发只有一次超时 #include<bits/stdc++.h> //CLOCKS_PER_SEC #define se s

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-K-Matrix Multiplication(矩阵乘法)

题目描述 In mathematics, matrix multiplication or matrix product is a binary operation that produces a matrix from two matrices with entries in a field, or, more generally, in a ring or even a semiring. The matrix product is designed for representing the

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-B-Perfect Numbers(完数)

题目描述 We consider a positive integer perfect, if and only if it is equal to the sum of its positive divisors less than itself. For example, 6 is perfect because 6 = 1 + 2 + 3. Could you write a program to determine if a given number is perfect or not?

hdu5512 Pagodas(2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学) )

Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 14 Accepted Submission(s): 13 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai M

第八届福建省大学生程序设计竞赛-重现赛

第八届福建省大学生程序设计竞赛-重现赛 B   计算几何 题意:问两个三角形是相交.包含还是相离. tags:套板子..求出相交的面积,再判断一下 /* 多边形相交面积模板 */ #define maxn 510 const double eps=1E-8; int sig(double d){ return(d>eps)-(d<-eps); } struct Point{ double x,y; Point(){} Point(double x,double y):x(x),y(y){} b

2016年中国大学生程序设计竞赛(合肥)-重现赛1008 HDU 5968

异或密码 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 19    Accepted Submission(s): 9 Problem Description 晨晨在纸上写了一个长度为N的非负整数序列{ai }.对于这个序列的一个连续子序列{al,al+1,…,ar }晨晨可以求出其中所有数异或的结果 alxoral+1xor...xo

2016年中国大学生程序设计竞赛(合肥)-重现赛1001 HDU 5961

传递 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 42    Accepted Submission(s): 16 Problem Description 我们称一个有向图G是传递的,当且仅当对任意三个不同的顶点a,,若G中有 一条边从a到b且有一条边从b到c ,则G中同样有一条边从a到c.我们称图G是一个竞赛图,当且仅当它是一个有

2016年中国大学生程序设计竞赛(合肥)-重现赛1009 HDU 5969

最大的位或 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 18    Accepted Submission(s): 17 Problem Description B君和G君聊天的时候想到了如下的问题.给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大.其中|表示按位或,即C. C++.

2016 CCPC 东北地区重现赛

1. 2016 CCPC 东北地区重现赛 2.总结:弱渣,只做出01.03.05水题 08   HDU5929 Basic Data Structure    模拟,双端队列 1.题意:模拟一个栈的操作,并在每次询问时,计算栈项到栈底元素nand位运算的值. 2.总结:思路就是看距离栈底最近的0的后面1的个数的奇偶.试了好多种办法,最后还是双端队列简便.总之,贼恶心的题.. #include<iostream> #include<cstring> #include<cmath

2017 acm / icpc shenyang 双十一单身狗温馨重现赛

上午做实验老师看错时间来晚了,20与非门一侧坏掉..于是做完实验就,光荣迟到了!!!QAQ... 一开始..看B题...喵喵喵??? J题...窝只会暴力..算了算了.. 刷新~ I题AC ratio 好像还可以!戳进去一看,a+b+c+d...一克斯Q斯咪?哭叽叽写了个大数加法,piapiapia乱敲一气竟然没崩,AC~~~是个好开头吖有木有~o(* ̄▽ ̄*)ブ~ K题就是小兔子跳啊跳~piapiapia求和然后选择一下从哪一端起跳,紫欣sama1A~ L题一开始对题意有误解,看懂样例之后就发