今天,2024.8.13,梦熊迎来了第三次模拟赛,虽然题目较为简单,但本蒟蒻切起来并非没有困难。
——————————————————————————————————
NO.1 余数
题目大意:有六个<=10的18次方的正整数为A,B,C,X,Y,Z,现在要求求出 (X* Y * Z) - (A * B * C)的结果对998244353取模。
那么这个题呢,思路非常简单,但是有一些坑点:1. 10的18次方,这个数据大小用int必爆,所以本题的所有变量都得开long long;2. 本题最大的坑点在于%998244353这里,你们考虑,如果将x直接×y,将结果乘z,不说最后,10的18次方成10的18次方,已经爆了long long。 。 。 。所以,先把每个数模上998244353,再做运算即可。
贴代码:
#include<bits/stdc++.h>
using namespace std;
long long x,y,z,a,b,c;
const long long mod=998244353;
int main(){
cin>>x>>y>>z>>a>>b>>c;
x%=mod;
y%=mod;
z%=mod;
a%=mod;
b%=mod;
c%=mod;
long long ans=(((x*y)%mod)*z)%mod;
long long ans1=(((a*b)%mod)*c)%mod;
if(ans<ans1){
ans+=mod;
}
cout<<(ans-ans1);
return 0;
}NO.2 原野之歌
题目大意:根据上图,给出t个询问,每个询问给出x,y,求坐标(x,y)属于哪个区域(1~8)
那么本题呢,一一判断对应区域即可。
贴代码:
#include<bits/stdc++.h>
using namespace std;
int t;
int x,y;
int main(){
cin>>t;
while(t--){
cin>>x>>y;
if(x==0 || y==0 || abs(x)==abs(y)){
cout<<0<<endl;
}
else{
if(abs(y)>abs(x)){
if(x>0){
if(y>0){
cout<<1<<endl;
}
else{
cout<<4<<endl;
}
}
else{
if(y>0){
cout<<8<<endl;
}
else{
cout<<5<<endl;
}
}
}
else{
if(x>0){
if(y>0){
cout<<2<<endl;
}
else{
cout<<3<<endl;
}
}
else{
if(y>0){
cout<<7<<endl;
}
else{
cout<<6<<endl;
}
}
}
}
}
return 0;
}NO.3 降雨量
题目大意:给出n个地点,给出t个询问,每个询问,给出l,r,w,让l地到r地的降雨量+w,问n个地点最终降雨量各是多少。
这个题呢,是经典的前缀和模板,首先,第一句话,也就是将[l,r]的区间每个加上w,那么,这样也就等于a[l]+=w,a[r+1]-=w,那么接下来用前缀和优化即可。
T3代码:
#include<bits/stdc++.h>
using namespace std;
int n,m;
int l,r,w;
int a[500005],b[500005];
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>l>>r>>w;
a[l]+=w;
a[r+1]-=w;
}
for(int i=1;i<=n;i++){
b[i]=b[i-1]+a[i];
cout<<b[i]<<' ';
}
return 0;
}NO.4 稻草富翁
小小的%你
题目大意:你有1单位的沙子,a单位沙子可以换b单位铅,c单位铅可以换d单位金子,e单位金子可以换e单位的沙子,你想要10^100单位的金子,如果可以通过要求获得,那么输出MEI,如果不行请输出FON。
话说怎么那么像mc里的黑商。
言归正传:这道题,只需要看一下,把这些微操都做一遍之后,如果>0,也就是能赚到东西,那就一定能骗来金子,那我们就判断一下,代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
double a,b,c,d,e,f,ans;
cin>>t;
while(t--){
cin>>a>>b>>c>>d>>e>>f;
ans=b/a*d/c*f/e;
if(ans<=1)cout<<"FON"<<endl;
else cout<<"MEI"<<endl;
}
return 0;
}别急开抄,看下后面网址。
(你们没有梦熊账号啊!)
你们知道了吧,出现这种情况的原因是你们少了一个特判,如果a=0时,我们只需要判断b*d是否大于0,再如果c=0,我们也就只需判断d是否>0,所以切记为了您在luogu能正常存活,请不要抄袭题解。
下面可以抄了
#include<bits/stdc++.h>
using namespace std;
int t;
int a,b,c,d,e,f,ans;
int main(){
cin>>t;
while(t--){
cin>>a>>b>>c>>d>>e>>f;
if((b*d*f>a*c*e) || (a==0 && b*d>0) || (c==0 && d>0)){
cout<<"MEI"<<endl;
}
else{
cout<<"FON"<<endl;
}
}
return 0;
}T4代码
