当前位置:网站首页>Niu Ke Xiaobaiyue Race 53 A-E
Niu Ke Xiaobaiyue Race 53 A-E
2022-07-30 21:06:00 【Salted egg_dd】
目录
A-Raining
原题链接<<See the original title here
思路:简单 略
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,x,ans;
ans=0;
scanf("%d%d%d%d",&a,&b,&c,&d);
scanf("%d",&x);
if(a<x)
printf("%d ",x-a);
else
printf("0 ");
if(b<x)
printf("%d ",x-b);
else
printf("0 ");
if(c<x)
printf("%d ",x-c);
else
printf("0 ");
if(d<x)
printf("%d ",x-d);
else
printf("0 ");
return 0;
}B-Kissing
原题链接-See the original title here
思路:Expand the formula and simplify it
,根据1-nThe summation formula can be found beforen项为(n)*(n+1)-n,Because the answer will be very large, it is necessary to model it,But the process volume will be huge,So the final result model is not acceptable,Every item must be modeled
#include <bits/stdc++.h>
using namespace std;
const int N=998244353;
int main()
{
long long int n;
scanf("%lld",&n);
printf("%lld\n",((n%N)*((n+1)%N)-n%N)%N);
return 0;
}
C. Missing
思路:模拟题,Just write as the title says
注意 The lexicographical output is availablestring,因为可以直接sort
#include <bits/stdc++.h>
using namespace std;
const int N=110;
string s,ss[N],sss[N];
queue <int> q;
int main()
{
int n,i;
cin>>s;
cin>>n;
int len=s.length();
for(i=1;i<=n;i++)
{
cin>>ss[i];
}
int res=0;
for(i=1;i<=n;i++)
{
int k=ss[i].length();
if(k!=len)
continue;
int sum=0;
for(int j=0;j<len;j++)
{
if(ss[i][j]==s[j])
sum++;
}
if(res<sum)
{
res=sum;
while(!q.empty())
q.pop();
q.push(i);
}
else if(res==sum)
q.push(i);
}
if(res==0)
{
sort(ss+1,ss+1+n);
for(i=1;i<=n;i++)
cout<<ss[i]<<endl;
}
else
{
int sum=q.size();
i=1;
while(!q.empty())
{
sss[i]=ss[q.front()];
q.pop();
i++;
}
sort(sss+1,sss+1+sum);
for(i=1;i<=sum;i++)
cout<<sss[i]<<endl;
}
return 0;
}
D.Breezing
思路:The difference between each two numbers is the largest,Then just take it1或者bi,运用dp,The two cases are counted separately,Take the maximum value at the end
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
typedef long long int ll;
int main()
{
ll n,i;
ll a[N],dp[N][3];//dp[i][1]表示第i个数取1的答案
cin>>n; //dp[i][2]表示第i个数取b[i]的答案
for(i=1;i<=n;i++) cin>>a[i];
dp[1][1]=0;
dp[1][2]=0;
for(i=2;i<=n;i++)
{
dp[i][1]=max(dp[i-1][1],dp[i-1][2]+a[i-1]-1);
dp[i][2]=max(dp[i-1][1]+a[i]-1,dp[i-1][2]+abs(a[i]-a[i-1]));
}
cout<<max(dp[n][1],dp[n][2])<<endl;
return 0;
}E.calling
思路:贪心思想,我们会发现,When the side length of the square is 6的时候,没有空余,边长是5的时候,会剩下11A cube that becomes one,边长为4时,会剩下5one becomes2的方块,以此类推,We fill each square,就是最好的情况.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll t,k,n,s,i;
ll a[10];
cin>>t;
while(t--)
{
cin>>s;
for(i=1;i<=6;i++) cin>>a[i];
if(a[6]!=0)
s=s-a[6];
if(a[5]!=0)
{
s=s-a[5];
a[1]=a[1]-a[5]*11;
}
if(a[4]!=0)
{
s=s-a[4];
a[2]=a[2]-5*a[4];
if(a[2]<=0)
{
a[1]-=-a[2]*4;
a[2]=0;
}
}
if(a[3]!=0)
{
if(a[3]%4==0)
s=s-a[3]/4;
else
{
s=s-a[3]/4-1;
k=a[3]%4;
if(k==1)
{
if(a[2]>0)
{
a[2]=a[2]-5;
a[1]=a[1]-7;
}
else a[1]-=27;
if(a[2]<0)
{
a[1]-=-a[2]*4;
a[2]=0;
}
}
else if(k==2)
{
if(a[2]>0)
{
a[2]=a[2]-3;
a[1]=a[1]-6;
}
else a[1]-=18;
if(a[2]<0)
{
a[1]-=-a[2]*4;
a[2]=0;
}
}
else if(k==3)
{
if(a[2]>0)
{
a[2]=a[2]-1;
a[1]=a[1]-5;
}
else a[1]-=9;
if(a[2]<0)
{
a[1]-=-a[2]*4;
a[2]=0;
}
}
}
}
if(a[2]>0)
{
if(a[2]%9==0)
s=s-a[2]/9;
else
{
s=s-a[2]/9-1;
k=a[2]%9;
a[1]=a[1]-(9-k)*4;
}
}
if(a[1]>0)
{
if(a[1]%36==0)
s=s-a[1]/36;
else
s=s-a[1]/36-1;
}
//for(i=1;i<=6;i++)
//cout<<a[i]<<' ';
if(s>=0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
F题还没做,will make up
边栏推荐
- 这本记述40年前历史的游戏书,预言的却是当下的事
- Deep Non-Local Kalman Network for VideoCompression Artifact Reduction
- 对List集合中每个对象元素按时间顺序排序
- Motion Tuned Spatio-temporal Quality Assessmentof Natural Videos
- Automatically generate test modules using JUnit4 and JUnitGenerator V2.0 in IDEA
- [Nuxt 3] (十四) Nuxt 生命周期
- 【机器学习】梯度下降背后的数学之美
- IDEA2018.3.5取消双击Shift快捷键
- 弹性盒子模型
- flowable工作流所有业务概念
猜你喜欢

这本记述40年前历史的游戏书,预言的却是当下的事

为什么那么多自学软件测试的人,后来都放弃了...
![[Machine Learning] The Beauty of Mathematics Behind Gradient Descent](/img/63/c9d5d9370c28dbce0195e1ff26869b.jpg)
[Machine Learning] The Beauty of Mathematics Behind Gradient Descent

MySQL的主从复制

@WebServlet注解(Servlet注解)

Babbitt | Metaverse Daily Must Read: The shuffling is coming, will the digital Tibetan industry usher in a new batch of leaders in the second half?Will there be new ways to play?...

mysql8安装步骤教程
![[Limited Time Bonus] 21-Day Learning Challenge - MySQL from entry to mastery](/img/12/f9fe60c7fc3d376aa95a4756541b61.png)
[Limited Time Bonus] 21-Day Learning Challenge - MySQL from entry to mastery

nVisual网络可视化管理平台功能和价值点

Cookie中的JSESSIONID说明
随机推荐
ENS emoji domain name is on fire!Hype or opportunity?
新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行
Mysql 回表
@RequestParam使用
[Nuxt 3] (十三) Nuxt 是如何工作的?
字节对齐之C语言犄角旮旯的知识
ENS 表情包域名火了!是炒作还是机遇?
Generate OOM records in a production environment. Conclusion: Don't be lazy to query useless fields unless you are completely sure.
KEIL problem: [keil Error: failed to execute 'C:\Keil\ARM\ARMCC']
MySQL Workbench 安装及使用
MySQL的DATE_FORMAT()函数将Date转为字符串
MySQL 高级(进阶) SQL 语句 (一)
MySQL8重置root账户密码图文教程
Swift RegexBuilder Vs. Raku Grammar
关于SFML Rect.inl文件报错的问题
C语言中指针没那么难~(2)【文章结尾有资料】
uni-app开发微信小程序踩坑
mysql8安装步骤教程
[The Beauty of Software Engineering - Column Notes] 31 | Is software testing responsible for product quality?
Flink_CDC搭建及简单使用