知识点模块

1.一个正方体x,y,z里面可以放多少个边长为a,b,c的长方体

ans=(x-a+1)*(y-b+1)*(z-c+1)

题解模块

A.Creating Words

交换两个字母的首字母即可swap实现即可

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
string a,b;
cin>>a>>b;
swap(a[0],b[0]);
cout<<a<<" "<<b;
cout<<endl;
} signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

B. Maximum Multiple Sum

要让一个数的倍数加起来总和最大,显然就是只要这个数不是3的时候,任何一个数(题给的数范围大于等于2)的2和其倍数的总和加起来最大。因为2的倍数会在这个范围里数量最多,不会有一个奇数比2的倍数多,任何偶数都是2的倍数

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
int n;
cin>>n;
if(n==3) cout<<3<<endl;
else cout<<2<<endl;
} signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

C. Good Prefixes

从左往右按顺序遍历,每次算前缀和,减掉当前遍历到的这些数的最大值,如果这个数等于该最大值,说明前面这个几个数加起来就是这个最大值,符合题意

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++) cin>>v[i];
int sum=0,maxx=0,ans=0;
for(int i=0;i<n;i++)
{
sum+=v[i];
maxx=max(maxx,v[i]);
if(sum-maxx==maxx) ans++;
}
cout<<ans<<endl;
} signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

D. Manhattan Circle

直接锁定最多#的这一行,然后记录一下最多有几个这个符号,记录一下这行的最后一个#的位置,然后就可以根据数量和最后一个位置推出他的中心

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
int n,m;
cin>>n>>m;
string s;
int maxx=-1,ans=0,cc=0;
for(int i=1;i<=n;i++)
{
cin>>s;
int cnt=0,pos=0;
for(int j=0;j<s.size();j++)
{
if(s[j]=='#') {
cnt++;
pos=j;
}
maxx=max(maxx,cnt);
if(maxx==cnt) ans=pos,cc=i;
}
} cout<<cc<<" "<<ans+1-maxx/2<<endl;
} signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

E. Secret Box

1.因为小方体的体积是k,所以边长一定是k的除数,那么就可以枚举a,b然后c用k%(a * b),如果不是0或者大于z退出循环

2.然后用知识点1,计算验证取最大值即可

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
int x,y,z,k;
int ans=0;
cin>>x>>y>>z>>k;
for(int i=1;i<=x;i++)
{
for(int j=1;j<=y;j++)
{
if(k%(i*j)) continue;//必须是k的除数
int c=k/(i*j);
if(c>z) continue;
int tt=(x-i+1)*(y-j+1)*(z-c+1);
ans=max(tt,ans);
}
}
cout<<ans<<endl;
} signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

F. Final Boss

1.使用set容器存放点,每个点{turn,i},就是攻击力的轮数和攻击力大小的索引,每一轮攻击完以后,删除这个点,然后存对应攻击可以使用的下一次轮数{turn+c[i],i},然后直到h<0即可

2.为什么这样可以满足最小回合呢?因为你第一轮如果没法将boss杀死以后,攻击力大的对应的使用轮数也会大,所以按照上述存放点是可以满足的

点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define all(v) v.begin(),v.end() void solve()
{
int h,n;
cin>>h>>n;
vector<int>a(n),c(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>c[i];
set<pii>se;
for(int i=0;i<n;i++) se.insert({1,i});
int ans=1;
while(h>0)
{
auto [turn,i]=*se.begin();
se.erase(se.begin());
h-=a[i];
ans=turn;
se.insert({turn+c[i],i});
}
cout<<ans<<endl; } signed main()
{ int t=1;
cin>>t;
while(t-- ) solve();
return 0;
}

G. D-Function

等我补补

Codeforces Round 952 (Div. 4)的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  10. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. .NET8.0多线程编码结合异步编码示例

    1.创建一个.NET8.0控制台项目来演示多线程的应用 2.快速创建一个线程 3.多次运行程序,可以得到输出结果 这就是多线程的特点 - 当多个线程并行执行时,它们的具体执行顺序是不确定的,除非我们使 ...

  2. Activiti、Flowable和Camunda选型和对比

    https://camunda.com/https://www.jianshu.com/p/5942c4ee513chttps://zhuanlan.zhihu.com/p/484107368http ...

  3. w3cschool-HBase官方文档-2数据模型

    HBase数据模型 2018-03-03 15:20 更新 HBase数据模型 在 HBase 中,数据模型同样是由表组成的,各个表中又包含数据行和列,在这些表中存储了 HBase 数据.在本节中,我 ...

  4. 一个登录功能也能玩出这么多花样?sa-token带你轻松搞定多地登录、单地登录、同端互斥登录

    需求场景 说起登录,你可能会不屑一顾,还有比这更简单的功能吗? 获取一下用户提交参数 username + password 和数据库中一比对,有记录返回[登录成功],无记录返回[用户名或密码错误] ...

  5. ulimit命令 控制服务器资源

    命   令:ulimit功   能:控制shell程序的资源语 法:ulimit [-aHS][-c <core文件上限>][-d <数据节区大小>][-f <文件大 小 ...

  6. nacos(五): 读取nacos配置并实现动态刷新

    接上回<nacos(四): 创建第一个消费者Conumer(单体)>,这一篇将介绍如何读取nacos中的配置,并实现动态刷新. 首先,需要先引入spring-cloud-starter-a ...

  7. DeepSeek智能编程

    技术背景 DeepSeek开源之后,让大家意识到了即时是在自己硬件性能一般的本地环境,也能够部署和使用大语言模型,真正实现了大模型的"私有化".而私有化大模型之后,自然是考虑生产力 ...

  8. Android高版本Service在后台一分钟被杀死

    最近公司出现了一个Bug,Service在后台写log时候一分钟左右被杀死,或者运行一会就被杀死了,上网搜了一下原来是Android高版本为了保护电量,流量什么的,会在后台杀死这些Service,现在 ...

  9. C#中对面向standard2.0、standard2.1的项目进行单元测试

    单元测试项目的目标框架 (TargetFramework或TargetFrameworks) 不能是standard2.0或standard2.1. 这是因为.NET Standard只是一个规范,它 ...

  10. 安卓线性布局LinearLayout

    1.weight权重解读 用法归纳: 按比例划分水平方向:将涉及到的View的android:width属性设置为0dp,然后设置为android weight属性设置比例即可. ` <Line ...