Codeforces Round #359 div2

Problem_A(CodeForces 686A):
题意:
\[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里没有\space d_i个冰淇淋, 那么这个孩纸就会失望的离开。\]
你初始有x个冰淇淋。
问最后有多少个孩纸失望的离开了。

思路:
模拟就好了, 判断当前的数目是否足够。

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 1000000
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
int n;
LL x;int main()
{LL res, child_num;scanf("%d %I64d", &n, &x);res = x;child_num = 0;LL total_num = 0;LL d;char op[2];for(int i = 0; i < n ;i ++){scanf("%s %I64d", op, &d);if(op[0] == '+')res += d;else if(op[0] == '-'){total_num ++;if(d <= res){res -= d;child_num ++;}}}printf("%I64d %I64d\n", res, total_num - child_num);return 0;
}

Problem_B(CodeForces 686B):
题意:
你能做如下操作:
[l, r]保证长度为偶数。
\[ 将(l, l+1), \cdots ,(r-1, r)交换。\]
你最后的目的是将其交换成一个非递减的数列。
请将交换过程中的l, r输出。

思路:
n<100, 可以很暴力的去冒泡, 因为最差的情况也不会超过100*100次。
而题目给的是2W次以内。
昂, 我比较傻逼的写了一个贪心。
每次去找最长的能够交换的区间, 然后进行操作, 一直到不能操作为止。

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 110
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
int n;
int a[MAXN];int find_(int l, int r, bool is_l)
{if(l > r) return l - 1;for(int i = l; i + 1 <= r; i +=2)if((a[i] <= a[i + 1] && is_l == false) || (a[i] > a[i + 1] && is_l == true)) return is_l ? i : i - 1;return is_l ? -1 : ((r - l + 1) % 2 == 0 ? r : r - 1); 
}void move_(int l, int r)
{for(int i = l; i < r; i += 2){int temp = a[i];a[i] = a[i + 1];a[i + 1] = temp;}
}
void show()
{for(int i = 1; i <= n; i ++)printf("%d ", a[i]);printf("\n");
}void deal()
{int l = 1, r;while(true){l = find_(1, n, true);if(l == -1){l = find_(2, n, true);if(l == -1) return ;}r = find_(l + 2, n, false);if(r == -1) return;// printf("==>%d %d\n", l, r);move_(l, r);// show();// paprintf("%d %d\n", l, r);}
}   int main()
{bool flag = true;a[0] = 0;scanf("%d", &n);flag = n == 1;for(int i = 1; i <= n; i ++){scanf("%d", &a[i]);if(a[i] > a[i - 1] && n && i > 1) flag = false;}if(!flag)deal();return 0;
}

Problem_C(CodeForces 686C):
题意:
给你n, m,将其转换成对应的7进制
然后从转换后的[0, n-1]中任选一个数, 再从转换后[0,m-1]中任选一个数。
必须要保证每个数字只出现一次, 即不会有重复的数字。
问你这样的组合有多少种。

思路:
因为是7进制, 而且要保证每位都不一样, 7进制只有7个数而已, 所以如果两个数的长度超过了7, 肯定不行。
\[ 再则, 要注意:转换成对应的7进制! 比如8, 转换成7进制, 是11, 那么这8个数就成了[00, 01, 02, \cdots , 10].而不是[0, 1, 2, 3, \cdots , 10]\]
\[ 所以可以先求出它们的长度len_n, len_m, 然后判断长度。\]
枚举0~n, 0~m。 将其分解成对应的7进制后判断是否出现相同数字即可。

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 1000000
#define MAXM 10
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
int n, m;
int left_len = 0, right_len = 0;int check(int x, int y)
{int used[MAXM] = {0};for(int i = x, k = 0; k < left_len; k ++, i /= 7)used[i % 7] += 1;for(int i = y, k = 0; k < right_len; k ++, i /= 7)used[i % 7] += 1;for(int i = 0; i < 7; i ++)if(used[i] > 1) return 0;return 1;
}int main()
{scanf("%d %d", &n, &m);left_len = right_len = 1;for(int i = 7; i < n; i *= 7)left_len ++;for(int i = 7; i < m; i *= 7)right_len ++;int ans = 0;if((left_len + right_len) <= 7){for(int i = 0; i < n; i ++)for(int j = 0; j < m; j ++)ans += check(i, j);}printf("%d\n", ans);return 0;
}

Orz 有点头痛,剩下的等明天再补。今天元气大伤

转载于:https://www.cnblogs.com/By-ruoyu/p/5674712.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/287023.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Flutter之测试Http和HttpClient

1 测试Http和HttpClient 导入包&#xff1a;在pubspec.yaml里面导入 http: ^0.12.2 main.dart里面导入 import package:http/http.dart as http; import dart:convert; import dart:io; 2 代码实现 import package:flutter/material.dart; import package:url_launcher/url_lau…

基于zookeeper的solrCloud集群搭建

1.安装及搭建相关环境 1.1环境准备 centos7,jdk1.8,tomcat8,zookeeper3.4.X,solr4.10.X 链接: https://pan.baidu.com/s/1i47IuKd 密码: emqt 2.zookeeper集群搭建 2.1复制zookeeper [rootMiWiFi-R3-srv ~]# mkdir /usr/local/solr-cloud [rootMiWiFi-R3-srv ~]# cp -r zookee…

【小白必懂】C语言求完全数

注意&#xff1a;学生党如果存在付费问题可以加我好友&#xff0c;我可以开单篇短时间的免费哟~ 私聊我就好~ 情景再现 &#x1f478;小媛&#xff1a;小C&#xff0c;你知道什么是完全数吗&#xff1f; &#x1f430;小C&#xff1a;知道呀&#xff0c;难道是今天老师又出题…

【三维激光扫描】第四章:点云数据处理

第一节 点云数据处理流程 由于外业获取点云数据时的多种因素影响,点云数据质量直接影响到三维建模等方面的应用,点云数据处理环节非常重要。本章主要介绍数据处理流程,数据的配准:滤波、缩减、分割、分类,最后介绍点云数据应用。 5.1 数据处理流程 5.1.1 数据处理软件 …

台式计算机硬件输入设备,台式电脑硬件配置有哪些

台式电脑硬件配置你知道有哪些?电脑的配置一般是指电脑的硬件配件的高档程度、性价比等&#xff0c;电脑的性能好坏主要决定于以下主要硬件配置。一起来看看台式电脑硬件配置有哪些&#xff0c;欢迎查阅!组装台式电脑配置1、实用性机型建议&#xff1a;首选1&#xff1a;intel…

mysql 如何用一条SQL将一张表里的数据插入到另一张表 3个例子

1. 表结构完全一样 insert into 表1select * from 表2 2. 表结构不一样&#xff08;这种情况下得指定列名&#xff09; insert into 表1 (列名1,列名2,列名3)select 列1,列2,列3 from 表2 3、只从另外一个表取部分值 insert into 表1 (列名1,列名2,列名3) values(列1,列2,(sel…

Android WebView和JavaScript交互

JavaScript在现在的网页设计中用得很多&#xff0c;Android 的WebView可以载入网页&#xff0c;WebView也设计了与JavaScript通信的桥梁。这篇主要介绍一下WebViewk控件如何和JavaScript进行交互。 WebView: WebView和网页相关的主要有一下几个方法&#xff1a;  setWebViewCl…

Microsoft Dev Box 带来全新云上开发体验

在 5 月 24 日, 微软的产品经理 Anthony Cangialosi 在 Azure 社区发布了一篇博客(Introducing Microsoft Dev Box)&#xff0c; 宣布推出 Microsoft Dev Box !这是一种新的云服务&#xff0c;托管在 Microsoft Azure 中&#xff0c;提供了一个开箱即用的开发工作站&#xff0c…

游戏开发如此简单?我直接创建了一个游戏场景【python 游戏实战 02】

前言 本系列文章将会以通俗易懂的对话方式进行教学&#xff0c;对话中将涵盖了新手在学习中的一般问题。此系列将会持续更新&#xff0c;包括别的语言以及实战都将使用对话的方式进行教学&#xff0c;基础编程语言教学适用于零基础小白&#xff0c;之后实战课程也将会逐步更新…

【三维激光扫描】第五章:基于点云数据的三维建模

第一节 绘制立面图 1. 打开CAD 2014,新建一个文件,模板选择acadiso.dwt,如下图。 2. 点击插入→创建点云。

Flutter之基本数据类型测试

1、Flutter的数据基本类型 Dart语言里一切皆为对象&#xff0c;所以如果没有将变初始化,那么它的默认值为null Number(int、doubkle)StringBoolean(bool) List Map2、测试代码 void testData() {//Number包含了int和doubleint a 4;int b 8;print(a b);int a1;if (a null)…

清北·NOIP2017济南考前冲刺班 DAY1 morning

立方数(cubic) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK定义了一个数叫“立方数”&#xff0c;若一个数可以被写作是一个正整数的3次方&#xff0c;则这个数就是立方数&#xff0c;例如1,8,27就是最小的3个立方数。 现在给定一个数P&#xff0c;LYK想要知道这个数…

2020美国纽约大学计算机科学排名,2020美国纽约大学排名第几

纽约大学在2020年《美国新闻与世界报道》美国全国性大学排名中排名第29名&#xff0c;在2020年QS世界大学排名中排名第39名。纽约大学专业排名QS世界大学生命科学与医学专业排名 2020年 第40名QS世界大学医学专业排名 2020年 第34名QS世界大学牙科专业排名 2020年 第14名QS世界…

saltstack 安装nginx

1. 目录结构[rootqing salt]# tree /srv/salt/nginx//srv/salt/nginx/-- config.sls-- files| -- nginx| -- nginx-1.0.15.tar.gz| -- nginx.conf| -- nginx_log_cut.sh| -- nginx-upstream-jvm-route-0.1.tar.gz-- init.sls-- install.sls1 directory, 8 files2. [r…

ArcGIS实验教程——实验三十一:ArcGIS构建泰森多边形(Thiessen Polygon)实例精解

泰森多边形是进行快速插值和分析地理实体影响区域的常用工具。例如,用离散点的性质描述多边形区域的性质,用离散点的数据计算泰森多边形区域的数据。泰森多边形可用于定性分析、统计分析和临近分析等。 ArcGIS实验视频教程合集:《ArcGIS实验教程从入门到精通》(附配套实验…

Python的魔法方法 .

基本行为和属性 __init__(self[,....])构造函数 . 在实例化对象的时候会自动运行 __del__(self)析构函数 . 在对象被回收机制回收的时候会被调用 __str__(self)输出函数 . 在实例对象请求输出的时候会被调用. __repr__(self). 当直接调用实例对象的时候会被调用 __new__(cls,[,…

游戏角色开始动起来了,真帅!【python 游戏实战 03】

前言 本系列文章将会以通俗易懂的对话方式进行教学&#xff0c;对话中将涵盖了新手在学习中的一般问题。此系列将会持续更新&#xff0c;包括别的语言以及实战都将使用对话的方式进行教学&#xff0c;基础编程语言教学适用于零基础小白&#xff0c;之后实战课程也将会逐步更新…

如何让 ASP.NET Core 支持绑定查询字符串中的数组

前言有网友在交流群中询问&#xff0c;如何让 ASP.NET Core 支持绑定查询字符串中的数组&#xff1a;据说&#xff0c;在 .NET 7 中已经支持了&#xff1a;但是&#xff0c;在这之前的 .NET 版本能实现相同功能吗&#xff1f;ByteArrayModelBinder这时&#xff0c;群里的网友提…

Docker Storm开发环境搭建

2019独角兽企业重金招聘Python工程师标准>>> 1. compose文件 storm-stack.yml version: 3.1services:zookeeper:image: zookeepercontainer_name: zookeeperrestart: alwaysports:- 2181:2181nimbus:image: stormcontainer_name: nimbuscommand: storm nimbusdepend…

Android之解决YouTubePlayerView启动在Android5.0左右的手机出现奔溃问题

1 问题 用YouTubePlayerView(https://github.com/PierfrancescoSoffritti/android-youtube-player)在部分Android5.0手机上初始化的时候出现手机奔溃,错误提示如下 关键日志如下: Error inflating class com.pierfrancescosoffritti.androidyoutubeplayer.core.player.v…