UCF Local Programming Contest 2016 3.29

Posted aixiaodezsh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UCF Local Programming Contest 2016 3.29相关的知识,希望对你有一定的参考价值。

C

#include <bits/stdc++.h>
using namespace std;

int h[55], l[55], t, n, k;

int main()
{
    scanf("%d", &t);
    for (int cas = 1; cas <= t; ++cas)
    {
        if (cas != 1) puts("");
        int ans = 0;
        scanf("%d%d", &n, &k);
        for (int i = 1; i <= n; ++i) h[i] = l[i] = 0;
        for (int i = 1; i <= k; ++i)
        {
            int a, b;
            scanf("%d%d", &a, &b);
            if (h[a] && l[b]) ++ans;
            h[a] = l[b] = 1;
        }
        printf("Strategy #%d: %d
", cas, ans);
    }
    return 0;
}

D

#include<iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
inline int read(){
    int x=0,y=1;
    char ch=getchar();
    while(ch<0||ch>9){
        if(ch==-){
            y=-1;
        }
        ch=getchar();
    }
    while(ch>=0&&ch<=9){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*y;
}
int a[50];
int main(){
    int T;
    T=read();
    for(int t=1;t<=T;t++){
        int n,m,it1=0,it2,it,ans,sum=0,DS,D,tmp;
        n=read();m=read();
        for(int i=1;i<=n;i++){
            a[i]=read();
            sum+=a[i];
            if(i<m)
                it1+=a[i];
        }
        it2=it1+a[m];
    
        DS=read();
        cout<<"CD #"<<t<<":"<<endl;
        for(int ds=1;ds<=DS;ds++){
            ans=0;
            D=read();
            for(int d=1;d<=D;d++){
                tmp=read();
                if(d%2){
                    ans+=tmp;
                    if(tmp%a[m]==0){
                        it=it2;
                    }
                    else{
                        it=tmp%a[m]+it1;
                    }
                }
                else{
                    ans+=(tmp/sum)*a[m];
                    tmp%=sum;
                    if(tmp<=it2-it){
                        ans+=tmp;
                    }
                    else{
                        ans+=it2-it;
                        if(tmp>=sum-it+it1){
                            ans+=tmp-(sum-it+it1);
                        }
                    }
                    it=(it+tmp)%sum;
                }    
            }
            cout<<ans<<endl;    
        }
        cout<<endl;
    }
    return 0;
}

J

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#define Max 1000
using namespace std;

int main(){
   
    int n;
    cin>>n;
    for(int i=2;i<n;i++){
        int x = n*i;
        int flag= 1;
        for(int j = 2;j<=sqrt(x);j++){
            if((n*i)%(j*j)==0){
                flag = 0;
            }
        }
        if(flag){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

 

以上是关于UCF Local Programming Contest 2016 3.29的主要内容,如果未能解决你的问题,请参考以下文章

UCF Local Programming Contest 2017(2020-04-06)

UCF Local Programming Contest 2012(Practice)补题

UCF Local Programming Contest 2016正式赛

UCF Local Programming Contest 2016 3.29

UCF Local Programming Contest 2015(Practice)个人分析

UCF Local Programming Contest 2012(Practice)