训练实录 | 2021牛客暑期多校训练营8

2021牛客暑期多校训练营8

传送门

A - Ares, Toilet Ares (待补)

solved by oye. 03:45:56(-7)

题意:

思路:

#include<iostream>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
#include<vector>
#include<ctype.h>
#include<deque>
#include<time.h>

using namespace std;
#define ll long long
const int maxn=1e5+10;
const int mod=4933;

ll pow_mod(ll x,ll n){
	ll res=1;
	while(n>0){
	if(n&1)res=res*x%mod;
	x=x*x%mod;
	n>>=1;
	}
	return res;
}

int main()
{	
	int n,m,k,a,l;
	cin>>n>>m>>k>>a>>l;
	ll fm=1,fz=1,sum=1;
	for(int i=0;i<k;i++){
		ll a2,b,x;
		scanf("%lld %lld %lld",&x,&a2,&b);
		if(x) sum=sum*(b-a2)%mod*pow_mod(b,mod-2)%mod;
	}
	sum=(sum+a)%mod;
	printf("%lld",sum);
}

E - Rise of Shadows

solved by Micky. 00:07:21(+)

题意: 给出一个年份,问年份是否为闰年并且为素数

思路: 众所周知,闰年一定是偶数,所以直接输出no即可

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#pragma warning (disable:4996)

typedef long long LL;
using namespace std;

#define ll long long
const int maxn = 1e6 + 10;

using namespace std;

bool isprime(int n) {         
    double n_sqrt = double(sqrt(n));
    if (n == 1)
        return false;
    if (n == 2 || n == 3)
        return true;
    if (n % 6 != 1 && n % 6 != 5)
        return false;

    for (int i = 5; i <= n_sqrt; i += 6)
        if (n % (i) == 0 | n % (i + 2) == 0)
            return false;
    return true;
}

int main()
{
    int n, t;
    cin >> t;
    while (t--) {
        scanf("%d", &n);
        if (((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0)) && isprime(n))
            printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

K - Yet Another Problem About Pi

solved by YukiSam. (after)

题意: 给出 w × d w×d w×d 为单位方格的图,要求画长为π的连续性的图形,规定一个单位方格内只要有图形一部分就算覆盖这个单位区域,求解最多能覆盖的方格数。

思路:
①确定以最小成本得到最大收益的画法是占据格点 ,可以看成在格点处画一个无穷小的圆,因为π是无理数,所以可以把格点的花费忽略不计。同时每占据一个格点就能答案cnt+=4
②考虑如何尽可能高性价比地画格点与格点间的路线,显然要么走最小单位长度 ww=min(w,d),要么走斜边 xie=sqrt(ww+dd)。同时,走最小单位长度对答案贡献为cnt+=2,走斜边对答案贡献为cnt+=3
③考虑如何合理规划走多少个斜边和多少个最小单位长度。证明可得只存在如下几种情况:


请添加图片描述

下证:


请添加图片描述

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const double pi=acos(-1.0);
ll t;
double w,d;
int main()
{
    scanf("%lld",&t);
    while(t--)
    {
        scanf("%lf%lf",&w,&d);
        double ww=min(w,d),xie=sqrt(w*w+d*d);
        ll nw=int(pi/ww),nx=int(pi/xie),cnt=max(4+nw*2,4+nx*3),ans;
        for(int i=1;i<=2 && i*ww<=pi;i++)
        {
            ans=4+2*i+3*int((pi-ww*i)/xie);
            cnt=max(cnt,ans);
        }
        for(int i=1;i<=2 && i*xie<=pi;i++)
        {
            ans=4+3*i+2*int((pi-xie*i)/ww);
            cnt=max(cnt,ans);
        }
        printf("%lld\n",cnt);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值