23 暑假友谊赛 No.3
23 暑假友谊赛 No.3
Problem - B - Codeforces
贪心吧,每次看哪块瓷砖划算就尽量多的放哪块
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,m,x,y;
cin >>n >> m >> x >> y;
vector<string> g(n);
for(auto &i : g) cin >> i;
int ans = 0;
for(int i =0;i < n;i ++){
for(int j = 0;j < m;j ++){
if(x * 2 <= y && g[i][j] == '.'){
ans += x;
}else{
int k = 0;
while(g[i][j] == '.' && j < m){
k++, j++;
}
ans += k / 2 * y + k % 2 * x;
}
}
}
cout << ans << endl;
}
return 0;
}
Problem - C - Codeforces
比较两个端点就行了
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int l1,l2,r1,r2;
cin >> l1 >> r1 >> l2 >> r2;
if(l1 >= r2){
cout << r1 << ' ' << l2 << endl;
}else
cout << l1 << ' ' << r2 << endl;
}
return 0;
}
Problem - D - Codeforces
推出\(a^2=2\times c -1\)就好做了,直接去枚举就行
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n ;
int ans = 0;
for(int i = 3;i <= n;i++){
int m = (i * i + 1) / 2;
if(m > n)
break;
if(2 * m - 1 == i * i)
ans ++;
}
cout << ans << endl;
}
return 0;
}
Problem - E - Codeforces
一个桶计数即可,然后取最大值.
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
vector<int> a(n),t(110);
for(auto &i : a) {
cin >> i;
t[i]++;
}
int ans = *max_element(t.begin(), t.end());
cout << ans << endl;
}
return 0;
}
Problem - G - Codeforces
看比最小数大的有多少
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n ;
vector<int> a(n);
for(auto &i : a) {
cin >> i;
}
int mi = *min_element(a.begin(), a.end());
int ans = 0;
for(auto i : a)
ans += (i > mi);
cout << ans << endl;
}
return 0;
}
Problem - I - Codeforces
分类讨论:
- m小于平均数的话,全给一个人就行了
- 大于的话,多出来的joker牌小于其他k-1个人就-1,能整除k-1个人就给k-1个人平均分配,然后m减去这个平均值,不能整除,说明有几张刚好多出来,m在那基础上再-1就行了
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,m,k;
cin >> n >> m >> k;
int card = n / k;
if(m <= card){
cout << m << endl;
}else{
m -= card;
k--;
if(m < k){
cout << card - 1 << endl;
}else if(m % k == 0){
cout << card - m / k << endl;
}else
cout << card - m / k - 1 << endl;
}
}
return 0;
}
Problem - J - Codeforces
唉,写了一堆判断,我考虑的真麻烦,懒得写了,建议看我学长的
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,k;
cin >> n >> k;
if(n % 2 == 0){
if(k >= n ){
if(k % n == 0)
cout << n << endl;
else
cout << k % n << endl;
}else{
cout << k << endl;
}
}else if(k * 2 <= n){
cout << k << endl;
}else{
int p = (k - 1) / (n / 2);
int now;
if(k % n == 0) now = n;
else now = k % n;
if((now + p) % n == 0)
cout << n << endl;
else
cout << (now + p) % n << endl;
}
}
return 0;
}
Problem - L - Codeforces
唉,破构造题,刚开始dfs写超时,后来打表找规律又找错了,麻了
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
for(int i = 1;i < n;i ++){
for(int j = i + 1;j <= n;j ++){
if(2 * (j - i) == n)
cout << 0 << ' ';
else if(2 * (j - i) < n)
cout << 1 << ' ';
else
cout << -1 << ' ';
}
}
cout << endl;
}
return 0;
}
Problem - M - Codeforces
双指针从两边求前缀后缀和,相等的时候记录一下就行了
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n ;
vector<int> a(n);
for(auto &i : a) cin >> i;
int A = a[0],B = a.back(), ans = 0;
for(int i = 0, j = n - 1;i < j;){
if(A == B)
ans = (i + 1) + (n - j);
if(A > B){
j--;
B += a[j];
}else{
i++;
A += a[i];
}
}
cout << ans << endl;
}
return 0;
}
总结
唉,刚开始编译器出问题了,半天没响应,本来最简单的签到题结果没看范围又wa了一发,后面又被那两只破猫换位置考虑了一堆写烦了,还有那个d题,刚开始读假了,没看到还要符合直角三角形,wa1发,后面那个破构造题,写个dfs超时,打表找规律找错,麻了,惹,感觉不如多来点二分贪心图论的题,补题看心情了,反正是越想越气\(:<\)
总结的总结
加训
23 暑假友谊赛 No.3的更多相关文章
- 合肥学院ACM集训队第一届暑假友谊赛 B FYZ的求婚之旅 D 计算机科学家 F 智慧码 题解
比赛网址:https://ac.nowcoder.com/acm/contest/994#question B FYZ的求婚之旅 思路: 然后用快速幂即可. 细节见代码: #include <i ...
- 暑假训练round 3 题解
今天做题运气出奇的好,除了几处小错误调试之后忘记改掉了……最后还AK了……虽然题目不难,学长也说是福利局,但是对个人的鼓励作用还是挺大的……至此暑假训练就结束了,也算没有遗憾……. 题解如下: Pro ...
- 20172305 暑假作业 之 TimeCalculate & Save Iron Man
20172305 暑假作业 之 TimeCalculate & Save Iron Man TimeCalculate 项目介绍 项目名称: TimeCalculate 项目简介: 本项目基于 ...
- STL 入门 (17 暑假集训第一周)
快速全排列的函数 头文件<algorithm> next_permutation(a,a+n) ---------------------------------------------- ...
- [置顶] 2013_CSUST暑假训练总结
2013-7-19 shu 新生训练赛:母函数[转换成了背包做的] shuacm 题目:http://acm.hdu.edu.cn/diy/contest_show.php?cid=20083总结:h ...
- 2014年暑假c#学习笔记目录
2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...
- Java开发中的23种设计模式详解
[放弃了原文访问者模式的Demo,自己写了一个新使用场景的Demo,加上了自己的理解] [源码地址:https://github.com/leon66666/DesignPattern] 一.设计模式 ...
- ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id
出现场景:当点击"分类"再返回"首页"时,发生error退出 BUG描述:Caused by: java.lang.IllegalArgumentExcep ...
- CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator
CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator 我还没有用过Compute Shader,所以现在把红宝书里的例子拿来了,加入CSharpGL中. ...
- ABP(现代ASP.NET样板开发框架)系列之23、ABP展现层——异常处理
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之23.ABP展现层——异常处理 ABP是“ASP.NET Boilerplate Project (ASP.NET ...
随机推荐
- dotnet 融合 Avalonia 和 UNO 框架
现在在 .NET 系列里面,势头比较猛的 UI 框架中,就包括了 Avalonia 和 UNO 框架.本文将告诉大家如何尝试在一个解决方案里面融合 Avalonia 和 UNO 两个框架,即在一个进程 ...
- 【论文阅读】TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Convex Optimization
参考与前言 Last edited time: August 3, 2022 10:04 AM Status: Reading Type: TRO Year: 2021 论文链接:https://ie ...
- 全志T3+FPGA国产核心板——Pango Design Suite的FPGA程序加载固化
本文主要基于紫光同创Pango Design Suite(PDS)开发软件,演示FPGA程序的加载.固化,以及程序编译等方法.适用的开发环境为Windows 7/10 64bit. 测试板卡为全志T3 ...
- Aspose Excel 单元格合并后边框显示不全
/// <summary> /// 解决合并后的单元格没有边框,设置合并单元格格式,让合并过的单元格中每一个单元格上都添加上加边框的样式 /// </summary> /// ...
- Java-Cookie客户端会话技术
会话技术 会话:一次对话中包含多次请求和响应 一次会话:浏览器第一次给服务器资源发送请求,会话建立,直到有一方断开为止 功能:在一次会话的范围内的多次请求间,共享数据 方式: 客户端会话技术:Cook ...
- 基于EF Core存储的Serilog持久化服务
前言 Serilog是 .NET 上的一个原生结构化高性能日志库,这个库能实现一些比内置库更高度的定制.日志持久化是其中一个非常重要的功能,生产环境通常很难挂接调试器或者某些bug的触发条件很奇怪.为 ...
- 利用opencv库使用Python将视频逐帧转为图片
做成型的语义分割软件需要,写了一个,在博客记录一下 import cv2 def video2pic(videoFile, outputFile): vc = cv2.VideoCapture(vid ...
- Java JVM——12. 垃圾回收理论概述
1.前言 1.1 什么是垃圾? 在提到什么是垃圾之前,我们先看下面一张图: 从上图我们可以很明确的知道,Java 和 C++ 语言的区别,就在于垃圾收集技术和内存动态分配上,C++ 语言没有垃圾收集技 ...
- 固定panel1,panel2适应窗体变化
固定panel1,panel2适应窗体变化 如果您想要固定 Panel1 并且让 Panel2 适应窗体大小的变化,可以使用以下方式设置 SplitContainer 的属性: ' 设置 Spli ...
- oeasy教您玩转vim - 12 - # 词头词尾
词头词尾 回忆上节课内容 我们这次学了向前一个单词 w 意思是 word 还学习了向后一个单词 b 意思是 backward 这俩命令都落在单词的第一个字母 还有什么好玩的命令吗? 动手练习 我们可以 ...