Codeforces Round 883 (Div. 3)
Codeforces Round 883 (Div. 3)
A. Rudolph and Cut the Rope
题意:有一颗糖果在连在绳子上,求剪短多少根绳子,他能落地
思路:只要绳子长度比钉子高度大就不用减
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, res = 0;
cin >> n;
while (n--) {
int a, b;
cin >> a >> b;
if (a > b) {
res++;
}
}
cout << res << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
B. Rudolph and Tic-Tac-Toe
题意:井字棋判断谁赢谁输
思路:8种情况,判断就行
#include <bits/stdc++.h>
using namespace std;
char mp[4][4];
void solve() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cin >> mp[i][j];
}
}
for (int i = 0; i < 3; i++) {
bool x = true, y = true;
for (int j = 1; j < 3; j++) {
if (x && mp[i][j] != mp[i][j - 1]) {
x = false;
}
if (y && mp[j][i] != mp[j - 1][i]) {
y = false;
}
if (!x && !y) break;
}
if (x && mp[i][0] != '.') {
cout << mp[i][0] << "\n";
return;
}
if (y && mp[0][i] != '.') {
cout << mp[0][i] << "\n";
return;
}
}
bool w = true;
for (int i = 1; i < 3; i++) {
if (mp[i][i] != mp[i - 1][i - 1]) {
w = false;
break;
}
}
if (w && mp[1][1] != '.') {
cout << mp[1][1] << "\n";
return;
}
w = true;
for (int i = 1; i < 3; i++) {
if (mp[i][2 - i] != mp[i - 1][3 - i]) {
w = false;
break;
}
}
if (w && mp[1][1] != '.') {
cout << mp[1][1] << "\n";
return;
}
cout << "DRAW\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
C. Rudolf and the Another Competition
题意:判断这个人在第几名
思路:优先级:题目数>罚时(重写cmp)老顽固真不喜欢运算符重载
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct Stu {
int num;//题数
int time;//罚时
int c;//那个b
};
bool cmp(Stu c, Stu b) {
if (c.num != b.num) {
return c.num > b.num;
}
if (c.time != b.time) {
return c.time < b.time;
}
return c.c > b.c;
}
void solve() {
int n, m, h;
cin >> n >> m >> h;
vector<Stu> a(n + 1);
for (int i = 1; i <= n; i++) {
vector<int> b(m + 1);
for (int j = 1; j <= m; j++) cin >> b[j];
sort(b.begin() + 1, b.end());
int cnt = 0, sum = 0, cur = 0;
for (int j = 1; j <= m; j++) {
if (cur + b[j] <= h) {
cnt++;
cur += b[j];
sum += cur;
}
}
a[i] = {cnt, sum, 0};
if (i == 1) a[i].c = 1;
}
sort(a.begin() + 1, a.end(), cmp);
for (int i = 1; i <= n; i++) {
if (a[i].c == 1) {
cout << i << endl;
return;
}
}
}
signed main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
D. Rudolph and Christmas Tree
题意:有n个等腰三角形,有重叠,求他们的面积
思路:总面积-重叠的面积
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int a[MAX];
void solve() {
int n;
double h, d;
cin >> n >> d >> h;
double s = h * n * d / 2;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
double res = 0;
for (int i = 0; i < n - 1; i++) {
if (a[i] + h > a[i + 1]) {
res += (double) (a[i] + h - a[i + 1]) * (a[i] + h - a[i + 1]) * d / (2 * h);
}
}
printf("%.6lf\n", s - res);
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
E1. Rudolf and Snowflakes (simple version)
题意:求n=k1+k2+..+k^x
思路:简单版直接爆爆爆爆力
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n;
cin>>n;
for(int i=2;i<=n;i++){
int sum = 1+i+i*i ;
int temp = i*i ;
if (sum > n) break;
while (sum < n)
{
temp *= i;
sum += temp;
}
if (sum == n)
{
cout << "YES\n" ;
return;
}
}
cout<<"NO\n";
}
signed main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
E2. Rudolf and Snowflakes (hard version)
他甚至爆unsigned long long 只能开int_128(shu)
题意:求n=k1+k2+..+k^x(变的是n的范围,所以暴力直接达咩)
$$
很明显等比数列求和:n=a_1*(1-k^x)/(1-q);
$$
思路:n<2e18最大也就2^64,x遍历[2,64],k遍历[2,1e9] (二分遍历)
二分板子:
while (l < r)
{
int mid = l + r >> 1;
if (check(mid)) r = mid; // check()判断mid是否满足性质
else l = mid + 1;
}
return l;
#include <bits/stdc++.h>
using namespace std;
#define int long long
int check(int k, int x) {//k底数x指数
__int128 cur = 1, res = 1;
for (int i = 1; i <= x; i++) {
cur *= k;
res += cur;
if (res >= 2e18) return 2e18;
}
return (int) (res);
}
void solve() {
int n;
cin >> n;
for (int x = 2; x <= 63; x++) {
int l = 2, r = 1e9;
while (l < r) {
int mid = (l + r) >> 1;
int t = check(mid, x);
if (t >= n)
r = mid;
else
l = mid + 1;
}
if (check(l, x) == n) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
signed main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Codeforces Round 883 (Div. 3)的更多相关文章
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- Web通用漏洞--RCE
Web通用漏洞--RCE 漏洞简介 RCE远程代码/命令执行漏洞,可以让攻击者直接向后台服务器远程注入操作系统命令或者代码,从而控制后台系统. RCE漏洞也分为代码执行漏洞和命令执行漏洞,所谓代码执行 ...
- 音视频FAQ(一):视频直播卡顿
一.摘要 本文介绍了视频直播卡顿的四个主要原因,用户网络问题.用户设备性能问题.技术路线的选择和实现问题.因本文主要阐述视频直播的卡顿,故技术路线的实现指的是:CDN供应商的实现问题,包含CDN性能不 ...
- 在 Visual Studio 2022 中使用文件对比
在最新版本的 Visual Studio 2022 中,加入了新的功能特性--"文件对比". 在开发过程中,开发人员有时会需要比对文件差异,特别是代码文件,之前很多时候是借助版本控 ...
- Go 上下文的理解与使用
为什么需要 context 在 Go 程序中,特别是并发情况下,由于超时.取消等而引发的异常操作,往往需要及时的释放相应资源,正确的关闭 goroutine.防止协程不退出而导致内存泄露.如果没有 c ...
- 深入探究API接口
作为程序员,我们经常会遇到需要获取外部数据或调用外部服务的情况.而API(Application Programming Interface,应用程序编程接口)接口就是这样的一种机制,它允许我们的应用 ...
- iOS交叉编译
编译objc程序 ~/toolchain4/pre/bin/arm-apple-darwin9-gcc -arch arm -lobjc -framework CoreFoundation -fram ...
- redhat7 team bonding 双网卡绑定 主备 负载均衡
team简介 team也被称为网络组,是将多个网卡聚合在一起,从而实现冗错和提高吞吐量.适用于redhat7.0以上版本,至多可支持8块网卡.team相对于之前的bonding技术,能提供更好的性能和 ...
- 基于AvaSpe 2048测定物体的光谱曲线
本文介绍基于AvaSpec-ULS2048x64光纤光谱仪测定植被.土壤等地物高光谱曲线的方法. AvaSpec是由荷兰著名的光纤光谱仪器与系统开发公司Avantes制造的系列高性能光谱仪,广 ...
- Springboot简单功能示例-4 自定义加密进行登录验证
springboot-sample 介绍 springboot简单示例 跳转到发行版 查看发行版说明 软件架构(当前发行版使用) springboot hutool-all 非常好的常用java工具库 ...
- grafana 配置自定义dashboard
本文为博主原创,转载请注明出处: 1.配置数据源 配置完成后,点击Save And Test,如果配置正确,页面则显示如下: 2.配置dashboard 点击 A ...