Codeforces Round #528 (Div. 2, based on Technocup 2019 Elimination Round 4)(有待更新)

题目链接:http://codeforces.com/contest/1087

第一题:

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

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))

#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)

const int  maxn =1e5+5;
const int mod=998244353;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
string s,ans="";
int len;
int main()
{
    cin>>s;
    len=s.size();
    int i=0,j=len-1;
    if(len&1) ans=ans+s[i++];
    while(i<j)
    {
        ans=s[j]+ans;
        ans=s[i]+ans;
        i++,j--;
    }
    cout<<ans<<endl;
    return 0;
}

第二题:

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

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))

#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)

const int  maxn =1e5+5;
const int mod=998244353;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int n,k;
int ans=2e9;
int main()
{
    cin>>n>>k;
    if(n<k) ans=min(n+k,ans);
    else ans=min(ans,n*k+1);
    for(int i=2;i*i<=n;i++)if(n%i==0){
        int x=i,y=n/i;
        if(y<k) ans=min(ans,y+x*k);
        if(x<k) ans=min(ans,x+y*k);
    }
    cout<<ans;
    return 0;
}

第三题:

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

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))

#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)

const int  maxn =1e5+5;
const int mod=998244353;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

struct node
{
    int x,y;
    bool operator<(const node& q) const
    {
        if(x==q.x) return y<q.y;
        return x<q.x;
    }
}a[3];

int main()
{
    cin>>a[0].x>>a[0].y;
    cin>>a[1].x>>a[1].y;
    cin>>a[2].x>>a[2].y;
    sort(a,a+3);///排序
    if(a[0].x==a[1].x&&a[1].x==a[2].x)
    {
        cout<<a[2].y-a[0].y+1<<endl;
        rep(i,a[0].y,a[2].y+1) cout<<a[0].x<<" "<<i<<endl;
    }
    else if(a[0].x==a[1].x)
    {
        int lb=min(a[0].y,a[2].y),ub=max(a[1].y,a[2].y);
        int ans=ub-lb+1+a[2].x-a[0].x;
        cout<<ans<<endl;
        rep(i,lb,ub+1) cout<<a[0].x<<" "<<i<<endl;
        rep(i,a[0].x+1,a[2].x+1) cout<<i<<" "<<a[2].y<<endl;
    }
    else if(a[1].x==a[2].x)
    {
        int lb=min(a[1].y,a[0].y),ub=max(a[2].y,a[0].y);
        int ans=ub-lb+1+a[2].x-a[0].x;
        cout<<ans<<endl;
        rep(i,lb,ub+1) cout<<a[1].x<<" "<<i<<endl;
        rep(i,a[0].x,a[1].x) cout<<i<<" "<<a[0].y<<endl;
    }
    else
    {
        int lb=min(a[1].y,min(a[0].y,a[2].y));
        int ub=max(a[1].y,max(a[0].y,a[2].y));
        int ans=ub-lb+1+(a[1].x-a[0].x+a[2].x-a[1].x);
        cout<<ans<<endl;
        rep(i,lb,ub+1) cout<<a[1].x<<" "<<i<<endl;
        rep(i,a[0].x,a[1].x) cout<<i<<" "<<a[0].y<<endl;
        rep(i,a[1].x+1,a[2].x+1) cout<<i<<" "<<a[2].y<<endl;
    }
    return 0;
}

第四题:

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

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))

#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)

const int  maxn =1e5+5;
const int mod=998244353;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int n,s,x,y;
int d[maxn];

int main()
{
    cin>>n>>s;
    rep(i,1,n)
    {
        cin>>x>>y;
        d[x]++,d[y]++;
    }
    int tmp=0;
    rep(i,1,n+1) if(d[i]==1) tmp++;
    printf("%.9f\n",1.0*s/tmp*2);
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值