2021牛客暑期多校训练营8

A.Ares, Toilet Ares

题意

题意很复杂,这道题主要时间花在读题上,总结来说,就是算 a + ∏ 1 − p i a+\prod{1-p_i} a+1pi p i p_i pi是题目所给的分数

思路

能读懂题意这题就不难,最难的知识点算是如何求逆元了

代码

/*
 * @Author: Icey_dying
 * @Date: 2021-08-09 15:27:56
 * @LastEditors: Icey_dying
 * @LastEditTime: 2021-08-12 23:17:11
 * @FilePath: \Icey_dying\competition\2021\2021.08\2021.08.09\A.cpp
 */
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=4933;
const ll maxn=5000+7;
using namespace std;
int Fac[maxn*2],Inv[maxn*2];

void Prepare(int n)//求逆元
{
    Inv[0] = Inv[1] = 1;
    for (int i = 2; i <= n; i ++)
        Inv[i] = mod - 1ll * (mod / i) * Inv[mod % i] % mod;
}

int n,m,k,a,l,x,y,z;
int main()
{
    int ans=1;
    cin>>n>>m>>k>>a>>l;
    Prepare(mod);
    for(int i=1;i<=k;i++){
        scanf("%d%d%d",&x,&y,&z);
        if(x==0) continue;
        if(ans){
            if(z!=y) ans=ans*(z-y)%mod*Inv[z]%mod;
            else ans=0;
        }
    }
    ans=(ans+a)%mod;
    cout<<ans<<endl;
    return 0;
}

E.Rise of Shadows

题意

当一个年份既是闰年又是素数的时候,输出 y e s yes yes,否则输出 n o no no

思路

闰年必是偶数,但偶数只有2是素数且2不是闰年,故直接输出 n o no no即可

代码

/*
 * @Author: NEFU AB_IN
 * @version: 1.0
 * @Date: 2021-08-09 12:05:53
 * @LastEditors: Icey_dying
 * @LastEditTime: 2021-08-09 12:15:53
 */
#include<bits/stdc++.h>
using namespace std;
#define LL                          long long
#define ULL                         unsigned long long
#define MP                          make_pair
#define SZ(X)                       ((int)(X).size())
#define IOS                         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(X)                    cout << #X << ": " << X << endl;
typedef pair<int , int>             PII;

int main()
{
    IOS;
    int t;
    cin >> t;
    while(t --){
        int n;
        cin >> n;
        cout << "no\n";
    }
    return 0;
}

K.Yet Another Problem About Pi

题意

先把地方分成一块块长为w,宽为d的方格,你可以画一个长度为 π \pi π的笔画,请问这个笔画能覆盖到几个方格中

思路

有两种画法,一种是沿着 m i n ( w , d ) min(w,d) min(w,d)的方向画,是 4 + 倍 数 × 2 4+倍数\times 2 4+×2;还有一种是沿着方格的对角线画,是 4 + 倍 数 × 3 4+倍数\times 3 4+×3
那么我们直接for循环一遍,找出它们两个结合的最大值即可

代码

/*
 * @Author: Icey_dying
 * @Date: 2021-08-09 15:59:26
 * @LastEditors: Icey_dying
 * @LastEditTime: 2021-08-09 15:59:26
 * @FilePath: \Icey_dying\competition\2021\2021.08\2021.08.09\K.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
int t;
double w,d;
int main()
{
    scanf("%d",&t);
    while(t--){
        scanf("%lf%lf",&w,&d);
        double minx=min(w,d);
        double hh=sqrt(w*w+d*d);
        int ans1,ans2,ans=0;
        for(ans1=0;ans1<=50;++ans1){
            ans2=floor((PI-minx*ans1)/hh);
            if(ans2<0) break;
            if(4+ans1*2+ans2*3>=ans) ans=4+ans1*2+ans2*3;
        }
        for(ans2=0;ans2<=50;++ans2){
            ans1=floor((PI-hh*ans2)/minx);
            if(ans1<0) break;
            if(4+ans1*2+ans2*3>=ans) ans=4+ans1*2+ans2*3;
        }
        printf("%d\n",ans);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值