2019牛客国庆集训派对day2
A(模拟):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 2e5+7;
- typedef long long ll;
- const ll mod = 1e9+7;
- using namespace std;
- int a[N];
- ll suf[N];
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- int n;
- while(cin>>n){
- for(int i=0;i<=n;i++){
- cin>>a[i];
- }
- for(int i=n;i>=0;i--)
- suf[i]=suf[i+1]+a[i];
- int ans;
- for(int i=0;i<=n;i++){
- if(suf[i]>=i){
- ans=i;
- }
- }
- cout<<ans<<endl;
- }
- }
B(思维):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 2e5+7;
- typedef long long ll;
- const ll mod = 1e9+7;
- using namespace std;
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- ll n;
- while(cin>>n){
- ll a; cin>>a;
- cout<<min(n,n%2==0?(n/2+a/2):(n/2+(a+1)/2))<<endl;
- }
- }
C(可持久化线段树):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 1e5+7;
- typedef long long ll;
- const ll mod = 1e9+7;
- using namespace std;
- struct tree{
- int l,r,v,ls,rs;
- }t[N<<5];
- ll a[N];
- int rt[N];
- int nico=0;
- int cnt=0;
- void build(int &p,int l,int r){
- p=++nico;
- t[p].l=l; t[p].r=r; t[p].v=0;
- if(l==r){
- return ;
- }
- int mid=(l+r)>>1;
- build(t[p].ls,l,mid);
- build(t[p].rs,mid+1,r);
- t[p].v=t[t[p].ls].v+t[t[p].rs].v;
- }
- void update(int &p,int last,int x,int v){
- p=++cnt;
- t[p]=t[last];
- if(t[p].l==t[p].r&&t[p].l==x){
- t[p].v+=v;
- return ;
- }
- int mid=(t[p].l+t[p].r)>>1;
- if(x<=mid) update(t[p].ls,t[last].ls,x,v);
- else update(t[p].rs,t[last].rs,x,v);
- t[p].v=t[t[p].ls].v+t[t[p].rs].v;
- }
- int query(int p,int last,int val){
- if(t[p].l==t[p].r){
- return t[p].l;
- }
- int mid=(t[p].l+t[p].r)>>1;
- int tt=t[t[p].rs].v-t[t[last].rs].v;
- if(tt+val<=mid) return query(t[p].ls,t[last].ls,tt+val);
- else return query(t[p].rs,t[last].rs,val);
- }
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- int n,q;
- while(cin>>n>>q){
- build(rt[0],1,n+1);
- cnt=nico;
- for(int i=1;i<=n;i++){
- cin>>a[i];
- update(rt[i],rt[i-1],a[i],1);
- }
- for(int i=1;i<=q;i++){
- int l,r; cin>>l>>r;
- int ans=query(rt[r],rt[l-1],0);
- cout<<ans<<"\n";
- }
- }
- }
F(排序):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 1e3+7;
- typedef long long ll;
- const ll mod = 1e9+7;
- using namespace std;
- struct node{
- ll a,b,c;
- int id;
- friend bool operator < (node i,node j){
- if((__int128)(i.a+i.b)*(j.a+j.b+j.c)==(__int128)(j.a+j.b)*(i.a+i.b+i.c)) return i.id<j.id;
- return (__int128)(i.a+i.b)*(j.a+j.b+j.c)<(__int128)(j.a+j.b)*(i.a+i.b+i.c);
- }
- }t[N];
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- int n;
- while(cin>>n){
- for(int i=0;i<n;i++){
- cin>>t[i].a>>t[i].b>>t[i].c;
- t[i].id=i+1;
- }
- sort(t,t+n);
- for(int i=0;i<n;i++){
- if(i==0) cout<<t[i].id;
- else cout<<" "<<t[i].id;
- }
- cout<<endl;
- }
- }
G(思维题):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 1e3+7;
- typedef long long ll;
- const ll mod = 1e9+7;
- using namespace std;
- vector<pair<int,int> > ss,tt;
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0); cout.tie(0);
- string s,t;
- while(cin>>s>>t){
- ss.clear(); tt.clear();
- int lens=s.size();
- int lent=t.size();
- int cnt=0;
- for(int i=0;i<lens;i++){
- if(s[i]=='c') cnt++;
- }
- for(int i=0;i<lent;i++)
- if(t[i]=='c') cnt--;
- if(cnt!=0){
- cout<<"No"<<endl;
- continue;
- }
- int numa=0,numb=0;
- for(int i=0;i<=lens;i++){
- if(i==lens||s[i]=='c'){
- ss.push_back(make_pair(numa&1,numb&1));
- numa=0;
- numb=0;
- }else{
- if(s[i]=='a') numa++;
- else numb++;
- }
- }
- numa=0; numb=0;
- for(int i=0;i<=lent;i++){
- if(i==lent||t[i]=='c'){
- tt.push_back(make_pair(numa&1,numb&1));
- numa=0;
- numb=0;
- }else{
- if(t[i]=='a') numa++;
- else numb++;
- }
- }
- bool f=1;
- for(int i=0;i<ss.size();i++){
- if(ss[i].first==tt[i].first&&ss[i].second==tt[i].second){
- }else{
- f=0;
- }
- }
- if(!f){
- cout<<"No"<<endl;
- }else{
- cout<<"Yes"<<endl;
- }
- }
- }
K(数学题):
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- const double eps = 1e-6;
- const int N = 2e5+7;
- typedef long long ll;
- typedef __int128 ull;
- const ll mod = 1e9+7;
- using namespace std;
- ull work(ll a,ll b,ll num){
- return b/num-(a-1)/num;
- }
- void print(__int128 x)
- {
- if (!x) return ;
- if (x < 0) putchar('-'),x = -x;
- print(x / 10);
- putchar(x % 10 + '0');
- }
- int main(){
- // ios::sync_with_stdio(false);
- // cin.tie(0); cout.tie(0);
- ll a,b,c,d;
- while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)){
- ull x=b-a+1,y=d-c+1;
- ull num18=work(a,b,2018);
- ull num19=work(a,b,1009);
- ull num12=work(a,b,2);
- ull num28=work(c,d,2018);
- ull num29=work(c,d,1009);
- ull num22=work(c,d,2);
- print(num18*(y-num28)+num28*(x-num18)+num18*num28+(num12-num18)*(num29-num28)+(num22-num28)*(num19-num18));
- puts("");
- }
- }
2019牛客国庆集训派对day2的更多相关文章
- 图论+思维(2019牛客国庆集训派对day2)
题意:https://ac.nowcoder.com/acm/contest/1107/J n个点的完全图编号0-n-1,第i个点的权值为2^i,原先是先手选取一些边,然后后手选取一些点,满足先手选取 ...
- 2019牛客国庆集训派对day5
2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...
- 牛客国庆集训派对Day2 Solution
A 矩阵乘法 思路: 1° 牛客机器太快了,暴力能过. #include <bits/stdc++.h> using namespace std; #define N 5000 in ...
- 2019 牛客国庆集训派对day1-C Distinct Substrings(exkmp+概率)
链接:https://ac.nowcoder.com/acm/contest/1099/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- 计算几何板子题【2019牛客国庆集训派对day7——三角形和矩形】【多边形相交的面积】
链接:https://ac.nowcoder.com/acm/contest/1112/J来源:牛客网 题目描述 Bobo 有一个三角形和一个矩形,他想求他们交的面积. 具体地,三角形和矩形由 8 个 ...
- 2019牛客国庆集训派对day7 A 2016
链接:https://ac.nowcoder.com/acm/problem/52800来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K ...
- 2019牛客国庆集训派对day1(A, B E F K)
链接:https://ac.nowcoder.com/acm/contest/1099#question A:可知符合条件的图中间肯定存在一个由1构成的矩形,找到由1构成矩形的边界,判断出现的1的数量 ...
- 牛客国庆集训派对Day2
题目链接:https://www.nowcoder.com/acm/contest/202/A A 题意:给出最大4096*64和64*4096的矩阵,其中有一个矩阵只含有0和1,问你它们相乘所得到得 ...
- 牛客国庆集训派对Day2 H 期望
小贝喜欢玩卡牌游戏.某个游戏体系中共有N种卡牌,其中M种是稀有的.小贝每次和电脑对决获胜之后都会有一个抽卡机会,这时系统会随机从N种卡中选择一张给小贝.普通卡可能多次出现,而稀有卡牌不会被重复抽到.小 ...
随机推荐
- 第1章 无所不在的JavaScript
traceur转码(编译)器 Babel转码(编译)器 JavaScript API 的核心组成部分:ECMASCcript, DOM, BOM 桌面应用:electron 移动应用:Apache C ...
- 【LeetCode】365.水壶问题
题目描述 解题思路 思路一:裴蜀定理-数学法 由题意,每次操作只会让桶里的水总量增加x或y,或者减少x或y,即会给水的总量带来x或y的变化量,转为数字描述即为:找到一对整数a,b使得下式成立: ax+ ...
- 执行py文件需要可执行权限吗?
案例解析 这个问题描述起来有点违反直觉,要执行一个文件难道不应该需要可执行权限吗?让我们先来看一个例子: # module1.py def test(): print ('hello world!') ...
- 深入剖析setState同步异步机制
关于 setState setState 的更新是同步还是异步,一直是人们津津乐道的话题.不过,实际上如果我们需要用到更新后的状态值,并不需要强依赖其同步/异步更新机制.在类组件中,我们可以通过thi ...
- ctfshow—web—web签到题
打开靶机,发现只有一句话 查看源码 发现一段字符串,猜是base64加密 拿到flag
- zabbix-server安装部署配置
zabbix-server安装部署配置 zabbixLinux安装部署安装脚本 1 一步一步部署 1.1 安装zabbix仓库源 这里安装阿里的zabbix仓库地址 选用zabbix版本3.4 rpm ...
- Vijos-P1103题解【线段树】
本文为原创,转载请注明:http://www.cnblogs.com/kylewilson/ 题目出处: https://www.vijos.org/p/1103 题目描述: 一条马路从数轴0到L,每 ...
- kaggle新手如何在平台学习大神的代码
原创:数据臭皮匠 [导读]Kaggle ,作为听说它很牛X但从未接触过的同学,可能仅仅了解这是一个参加数据挖掘比赛的网站,殊不知Kaggle也会有赛题相关的数据集, 比如我们熟知的房价预测.泰坦尼克 ...
- Java多线程基础知识笔记(持续更新)
多线程基础知识笔记 一.线程 1.基本概念 程序(program):是为完成特定任务.用某种语言编写的一组指令的集合.即指一段静态的代码,静态对象. 进程(process):是程序的一次执行过程,或是 ...
- windows上传ipa到苹果开发者中(app store)的方法
假如你已经使用过苹果开发者中心上架app,你肯定知道在苹果开发者中心的web界面,无法直接提交ipa文件,而是需要使用第三方工具,将ipa文件上传到构建版本,开发者中心才能在构建版本里选择构建版本上架 ...