A.Ares, Toilet Ares
题意
题意很复杂,这道题主要时间花在读题上,总结来说,就是算 a + ∏ 1 − p i a+\prod{1-p_i} a+∏1−pi, 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;
}