SMU Summer 2023 Contest Round 2
SMU Summer 2023 Contest Round 2
A. Treasure Hunt
当\(x1 - x2\)的差值与\(y1-y2\)的差值都能被\(x,y\)整除时,且商之和为2的倍数就一定可以到达
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f
using namespace std;
const int N = 2e5 + 10, mod = 1e18;
int n,m,t,k;
void solve(){
int x1,y1,x2,y2,x,y;
cin >> x1 >> y1 >> x2 >> y2 >> x >> y;
int dx = x2 - x1, dy = y2 - y1;
if(dx % x == 0 && dy % y == 0 && ((dx / x + dy / y) % 2 == 0)){
cout << "YES" << endl;
}else
cout << "NO" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
/*
*/
B. Makes And The Product
对数组排序,显然前三个的积一定是最小的.
取前三个值为\(a1,a2,a3\),因为三种结果都只看\(a3\)的关系,记\(sum\)为\(a3\)的数量.
结果分三种情况 (实际上应该是四种,不过有两组重复了:
- \(a1 = a2 = a3\) 时,说明三个是一样的,只需要在\(sum\)中任取三个即可,即\(C_{sum}^{3}\),也可以用公式\(\frac{sum * (sum - 1) * (sum - 2)}{6}\).
- \(a1 = a2 < a3\) 或者 $a1 < a2 < a3 $ 时,这两种都是一样的,因为前两个都是必须选,然后再从 \(sum\) 中选一个,答案就是 \(sum\) .
- \(a1 < a2 = a3\)时,则\(a1\)必选,然后\(a2,a3\)再从\(sum\)中任选两个即可,即\(C_{sum} ^ {2}\),也可以用公式\(\frac{sum * (sum - 1)}{2}\).
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f
using namespace std;
const int N = 2e5 + 10, mod = 1e18;
map<int, int > mp;
int n,m,t,k;
void solve(){
cin >> n;
vector<int> a(n);
for(auto &i : a)
cin >> i;
sort(a.begin(), a.end());
int a1 = a[0],a2 = a[1],a3 = a[2];
int sum = 0;
for(int i = 0;i < n;i ++){
sum += (a[i] == a3);
}
int ans = 0;
if(a1 == a2 && a2 == a3){
ans = sum * (sum - 1) * (sum - 2) / 6;
}else if(a1 == a2 && a2 < a3 || a1< a2 && a2 < a3){
ans = sum;
}else if(a1 < a2 && a2 == a3){
ans = sum * (sum - 1)/ 2;
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
/*
*/
C. Really Big Numbers
由于给定的大数在答案中是单调递增的,所以我们可以对答案进行二分,二分的左边界就是满足条件的最小的大数,这个数到\(n\)之间的都算大数,若左边界大于了n说明没有满足条件的
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n,m,t,k;
void solve(){
int s;
cin >> n >> s;
auto get = [&](int x){
int res = 0;
while(x){
res += x % 10;
x /= 10;
}
return res;
};
int ans = 0, l = 1, r = 1e18;
while(l <= r){
int mid = (l + r) >> 1;
if(mid - get(mid) >= s){
r = mid - 1;
// cout << mid << endl;
}else l = mid + 1;
}
cout << (l > n ? 0 : n - l + 1) << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
/*
*/
SMU Summer 2023 Contest Round 2的更多相关文章
- 2015 Astar Contest - Round 3 题解
1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...
- Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression
题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd
http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...
- Codeforces 240 F. TorCoder
F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...
- cf499B-Lecture 【map】
http://codeforces.com/problemset/problem/499/B B. Lecture You have a new professor of graph theo ...
- Codeforces 240F. TorCoder 线段树
线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...
- 物联网学生科协第三届H-star现场编程比赛
问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...
- [cf contest 893(edu round 33)] F - Subtree Minimum Query
[cf contest 893(edu round 33)] F - Subtree Minimum Query time limit per test 6 seconds memory limit ...
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
随机推荐
- 2019-2020 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) M. SmartGarden 题解
cf1250 M. SmartGarden 完全不会做 orz,在 cf 上看到了有趣的做法. 通读题意后可以发现是对于每一次操作,要求选出的行集合 \(R\) 和列集合 \(C\) 要满足如下条件: ...
- Vue3 中的 v-bind 指令:你不知道的那些工作原理
前言 v-bind指令想必大家都不陌生,并且都知道他支持各种写法,比如<div v-bind:title="title">.<div :title="t ...
- 多个子节点收集日志-主节点上传到HDFS
Master: ---------------------- #MasterAgentMasterAgent.channels = c1MasterAgent.sources = s1MasterAg ...
- 记一次win10 python -m http.server 启动后无法访问的经历
前言 最近需要在win10上使用python创建一个http文件服务(默认端口 8000),结果执行了 python3 -m http.server -b 0.0.0.0 后,发现服务跑起来了,但浏览 ...
- GCC8 编译优化 BUG 导致的内存泄漏
1. 背景 1.1. 接手老系统 最近我们又接手了一套老系统,老系统的迭代效率和稳定性较差,我们打算做重构改造,但重构周期较长,在改造完成之前还有大量的需求迭代.因此我们打算先从稳定性和迭代效率出发做 ...
- Qt 学习笔记 - 第四章 - Qt的三驾马车之 - 网络编程
Qt 学习笔记全系列传送门: Qt 学习笔记 - 第一章 - 快速开始.信号与槽 Qt 学习笔记 - 第二章 - 添加图片.布局.界面切换 Qt 学习笔记 - 第三章 - Qt的三驾马车之一 - 串口 ...
- java springboot监听事件和处理事件
在Spring Boot中,监听和处理事件是一种常用的模式,用于在应用程序的不同部分之间传递信息.Spring 的事件发布/订阅模型允许我们创建自定义事件,并在这些事件发生时由注册的监听器进行处理.这 ...
- Java 数据类型的包装数据类型
什么是包装数据类型 Java是一个面向对象的编程语言,但基本类型并不具有对象的性质,为了让基本类型也具有对象的特征,就出现了包装类型. 集合框架里面需要存储对象,不能存储基本数据类型,所以需要存储包装 ...
- Spring里面bean的生命周期里面的init和destroy方法
package net.cybclass.sp; import net.cybclass.sp.domain.Video; import net.cybclass.sp.domain.Video2; ...
- Oracle ROW_NUMBER() OVER()函数用法详解 (分组排序 例子多)
转载☞:https://blog.csdn.net/qq_25221835/article/details/82762416 ROW_NUMBER 语法 语法格式:row_number() over( ...