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.pswp.cn/news/287023.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/287023.shtml
英文地址,請注明出處:http://en.pswp.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…