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\)的数量.

结果分三种情况 (实际上应该是四种,不过有两组重复了​:

  1. \(a1 = a2 = a3\) 时,说明三个是一样的,只需要在\(sum\)中任取三个即可,即\(C_{sum}^{3}\),也可以用公式\(\frac{sum * (sum - 1) * (sum - 2)}{6}\).
  2. \(a1 = a2 < a3\) 或者 $a1 < a2 < a3 $ 时,这两种都是一样的,因为前两个都是必须选,然后再从 \(sum\) 中选一个,答案就是 \(sum\) .
  3. \(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的更多相关文章

  1. 2015 Astar Contest - Round 3 题解

    1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...

  2. Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression

    题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...

  3. 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 ...

  4. Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd

    http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...

  5. Codeforces 240 F. TorCoder

    F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...

  6. cf499B-Lecture 【map】

    http://codeforces.com/problemset/problem/499/B B. Lecture     You have a new professor of graph theo ...

  7. Codeforces 240F. TorCoder 线段树

    线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...

  8. 物联网学生科协第三届H-star现场编程比赛

    问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...

  9. [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 ...

  10. 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest

    题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. PhantomReference 和 WeakReference 究竟有何不同

    本文基于 OpenJDK17 进行讨论,垃圾回收器为 ZGC. 提示: 为了方便大家索引,特将在上篇文章 <以 ZGC 为例,谈一谈 JVM 是如何实现 Reference 语义的> 中讨 ...

  2. 阿里云 腾讯云上搭建Samba服务

    对于这个主题,鄙人走了很久的坑,最后很抱歉的告诉你. 运营商把Samba服务的端口全部封掉了,所以你根本就没办法访问! 那怎么办,我Windows空间不够,又不想浪费云上的资源. 那就用FTP代替它吧 ...

  3. Ubuntu 18.04 安装OneDrive自动同步

    Ubuntu 18.04 安装OneDrive自动同步 Windows10系统已经自带了OneDrive的自动同步功能,对于多设备用户而言已经成为了一个非常方便传输保存文件的途径,在Ubuntu下也有 ...

  4. 在Linux中使用crontab

    背景 虽然不是专业运维,但是在嵌入式开发中还是需要懂一点的.部门内部搞服务器最厉害的就是我了,汗. 参考: https://blog.csdn.net/longgeaisisi/article/det ...

  5. QT学习:04 代码化的界面绘制

    --- title: framework-cpp-qt-04-代码化的界面绘制 EntryName: framework-cpp-qt-04-ui-design-by-code date: 2020- ...

  6. 【排行榜】Carla leaderboard 排行榜 运行与参与手把手教学

    此分支主要供参与leaderboard排名使用,介绍如何构建队伍,提交自己代码,此部分较为简单,主要是基本教学与演示:后续可以参考更多的开源代码进行学习等. 基本参与此榜单的大多都是学校和实验室,还是 ...

  7. linux scp自动填充密码脚本

    在linux上使用scp命令传输文件时,每传输一次,都要填写目标服务器的登录密码,十分麻烦. 配置系统密钥又比较复杂,于是想到的使用expect写一个自动填充密码的脚本,脚本内容如下: scp.sh ...

  8. Golang channel底层是如何实现的?(深度好文)

    Hi 你好,我是k哥.大厂搬砖6年的后端程序员. 我们知道,Go语言为了方便使用者,提供了简单.安全的协程数据同步和通信机制,channel.那我们知道channel底层是如何实现的吗?今天k哥就来聊 ...

  9. Vscode连接虚拟机报错

    Vscode 连接虚拟机报错问题解决 问题解释 Permission denied, please try again.出现这个问题通常表示身份验证失败. 可能的原因有 SSH用户密码错误 SSH端口 ...

  10. 洛谷P6397

    [COI2008] GLASNICI 题意描述 输入 3.000 2 0.000 6.000 输出 1.500 点拨 二分答案的题一般来说可以用答案去检验假设. 对于这道题,每一个信使的最佳走法是保证 ...