A(模拟):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 2e5+7;
  6. typedef long long ll;
  7. const ll mod = 1e9+7;
  8. using namespace std;
  9. int a[N];
  10. ll suf[N];
  11. int main(){
  12. ios::sync_with_stdio(false);
  13. cin.tie(0); cout.tie(0);
  14. int n;
  15. while(cin>>n){
  16. for(int i=0;i<=n;i++){
  17. cin>>a[i];
  18. }
  19. for(int i=n;i>=0;i--)
  20. suf[i]=suf[i+1]+a[i];
  21. int ans;
  22. for(int i=0;i<=n;i++){
  23. if(suf[i]>=i){
  24. ans=i;
  25. }
  26. }
  27. cout<<ans<<endl;
  28. }
  29. }

B(思维):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 2e5+7;
  6. typedef long long ll;
  7. const ll mod = 1e9+7;
  8. using namespace std;
  9. int main(){
  10. ios::sync_with_stdio(false);
  11. cin.tie(0); cout.tie(0);
  12. ll n;
  13. while(cin>>n){
  14. ll a; cin>>a;
  15. cout<<min(n,n%2==0?(n/2+a/2):(n/2+(a+1)/2))<<endl;
  16. }
  17. }

C(可持久化线段树):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 1e5+7;
  6. typedef long long ll;
  7. const ll mod = 1e9+7;
  8. using namespace std;
  9. struct tree{
  10. int l,r,v,ls,rs;
  11. }t[N<<5];
  12. ll a[N];
  13. int rt[N];
  14. int nico=0;
  15. int cnt=0;
  16. void build(int &p,int l,int r){
  17. p=++nico;
  18. t[p].l=l; t[p].r=r; t[p].v=0;
  19. if(l==r){
  20. return ;
  21. }
  22. int mid=(l+r)>>1;
  23. build(t[p].ls,l,mid);
  24. build(t[p].rs,mid+1,r);
  25. t[p].v=t[t[p].ls].v+t[t[p].rs].v;
  26. }
  27. void update(int &p,int last,int x,int v){
  28. p=++cnt;
  29. t[p]=t[last];
  30. if(t[p].l==t[p].r&&t[p].l==x){
  31. t[p].v+=v;
  32. return ;
  33. }
  34. int mid=(t[p].l+t[p].r)>>1;
  35. if(x<=mid) update(t[p].ls,t[last].ls,x,v);
  36. else update(t[p].rs,t[last].rs,x,v);
  37. t[p].v=t[t[p].ls].v+t[t[p].rs].v;
  38. }
  39. int query(int p,int last,int val){
  40. if(t[p].l==t[p].r){
  41. return t[p].l;
  42. }
  43. int mid=(t[p].l+t[p].r)>>1;
  44. int tt=t[t[p].rs].v-t[t[last].rs].v;
  45. if(tt+val<=mid) return query(t[p].ls,t[last].ls,tt+val);
  46. else return query(t[p].rs,t[last].rs,val);
  47. }
  48. int main(){
  49. ios::sync_with_stdio(false);
  50. cin.tie(0); cout.tie(0);
  51. int n,q;
  52. while(cin>>n>>q){
  53. build(rt[0],1,n+1);
  54. cnt=nico;
  55. for(int i=1;i<=n;i++){
  56. cin>>a[i];
  57. update(rt[i],rt[i-1],a[i],1);
  58. }
  59. for(int i=1;i<=q;i++){
  60. int l,r; cin>>l>>r;
  61. int ans=query(rt[r],rt[l-1],0);
  62. cout<<ans<<"\n";
  63. }
  64. }
  65. }

F(排序):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 1e3+7;
  6. typedef long long ll;
  7. const ll mod = 1e9+7;
  8. using namespace std;
  9. struct node{
  10. ll a,b,c;
  11. int id;
  12. friend bool operator < (node i,node j){
  13. 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;
  14. return (__int128)(i.a+i.b)*(j.a+j.b+j.c)<(__int128)(j.a+j.b)*(i.a+i.b+i.c);
  15. }
  16. }t[N];
  17. int main(){
  18. ios::sync_with_stdio(false);
  19. cin.tie(0); cout.tie(0);
  20. int n;
  21. while(cin>>n){
  22. for(int i=0;i<n;i++){
  23. cin>>t[i].a>>t[i].b>>t[i].c;
  24. t[i].id=i+1;
  25. }
  26. sort(t,t+n);
  27. for(int i=0;i<n;i++){
  28. if(i==0) cout<<t[i].id;
  29. else cout<<" "<<t[i].id;
  30. }
  31. cout<<endl;
  32. }
  33. }

G(思维题):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 1e3+7;
  6. typedef long long ll;
  7. const ll mod = 1e9+7;
  8. using namespace std;
  9. vector<pair<int,int> > ss,tt;
  10. int main(){
  11. ios::sync_with_stdio(false);
  12. cin.tie(0); cout.tie(0);
  13. string s,t;
  14. while(cin>>s>>t){
  15. ss.clear(); tt.clear();
  16. int lens=s.size();
  17. int lent=t.size();
  18. int cnt=0;
  19. for(int i=0;i<lens;i++){
  20. if(s[i]=='c') cnt++;
  21. }
  22. for(int i=0;i<lent;i++)
  23. if(t[i]=='c') cnt--;
  24. if(cnt!=0){
  25. cout<<"No"<<endl;
  26. continue;
  27. }
  28. int numa=0,numb=0;
  29. for(int i=0;i<=lens;i++){
  30. if(i==lens||s[i]=='c'){
  31. ss.push_back(make_pair(numa&1,numb&1));
  32. numa=0;
  33. numb=0;
  34. }else{
  35. if(s[i]=='a') numa++;
  36. else numb++;
  37. }
  38. }
  39. numa=0; numb=0;
  40. for(int i=0;i<=lent;i++){
  41. if(i==lent||t[i]=='c'){
  42. tt.push_back(make_pair(numa&1,numb&1));
  43. numa=0;
  44. numb=0;
  45. }else{
  46. if(t[i]=='a') numa++;
  47. else numb++;
  48. }
  49. }
  50. bool f=1;
  51. for(int i=0;i<ss.size();i++){
  52. if(ss[i].first==tt[i].first&&ss[i].second==tt[i].second){
  53.  
  54. }else{
  55. f=0;
  56. }
  57. }
  58. if(!f){
  59. cout<<"No"<<endl;
  60. }else{
  61. cout<<"Yes"<<endl;
  62. }
  63. }
  64. }

K(数学题):

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int inf = 0x3f3f3f3f;
  4. const double eps = 1e-6;
  5. const int N = 2e5+7;
  6. typedef long long ll;
  7. typedef __int128 ull;
  8. const ll mod = 1e9+7;
  9. using namespace std;
  10. ull work(ll a,ll b,ll num){
  11. return b/num-(a-1)/num;
  12. }
  13. void print(__int128 x)
  14. {
  15. if (!x) return ;
  16. if (x < 0) putchar('-'),x = -x;
  17. print(x / 10);
  18. putchar(x % 10 + '0');
  19. }
  20. int main(){
  21. // ios::sync_with_stdio(false);
  22. // cin.tie(0); cout.tie(0);
  23. ll a,b,c,d;
  24. while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)){
  25. ull x=b-a+1,y=d-c+1;
  26. ull num18=work(a,b,2018);
  27. ull num19=work(a,b,1009);
  28. ull num12=work(a,b,2);
  29. ull num28=work(c,d,2018);
  30. ull num29=work(c,d,1009);
  31. ull num22=work(c,d,2);
  32. print(num18*(y-num28)+num28*(x-num18)+num18*num28+(num12-num18)*(num29-num28)+(num22-num28)*(num19-num18));
  33. puts("");
  34. }
  35. }

2019牛客国庆集训派对day2的更多相关文章

  1. 图论+思维(2019牛客国庆集训派对day2)

    题意:https://ac.nowcoder.com/acm/contest/1107/J n个点的完全图编号0-n-1,第i个点的权值为2^i,原先是先手选取一些边,然后后手选取一些点,满足先手选取 ...

  2. 2019牛客国庆集训派对day5

    2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...

  3. 牛客国庆集训派对Day2 Solution

    A    矩阵乘法 思路: 1° 牛客机器太快了,暴力能过. #include <bits/stdc++.h> using namespace std; #define N 5000 in ...

  4. 2019 牛客国庆集训派对day1-C Distinct Substrings(exkmp+概率)

    链接:https://ac.nowcoder.com/acm/contest/1099/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...

  5. 计算几何板子题【2019牛客国庆集训派对day7——三角形和矩形】【多边形相交的面积】

    链接:https://ac.nowcoder.com/acm/contest/1112/J来源:牛客网 题目描述 Bobo 有一个三角形和一个矩形,他想求他们交的面积. 具体地,三角形和矩形由 8 个 ...

  6. 2019牛客国庆集训派对day7 A 2016

    链接:https://ac.nowcoder.com/acm/problem/52800来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K ...

  7. 2019牛客国庆集训派对day1(A, B E F K)

    链接:https://ac.nowcoder.com/acm/contest/1099#question A:可知符合条件的图中间肯定存在一个由1构成的矩形,找到由1构成矩形的边界,判断出现的1的数量 ...

  8. 牛客国庆集训派对Day2

    题目链接:https://www.nowcoder.com/acm/contest/202/A A 题意:给出最大4096*64和64*4096的矩阵,其中有一个矩阵只含有0和1,问你它们相乘所得到得 ...

  9. 牛客国庆集训派对Day2 H 期望

    小贝喜欢玩卡牌游戏.某个游戏体系中共有N种卡牌,其中M种是稀有的.小贝每次和电脑对决获胜之后都会有一个抽卡机会,这时系统会随机从N种卡中选择一张给小贝.普通卡可能多次出现,而稀有卡牌不会被重复抽到.小 ...

随机推荐

  1. 第1章 无所不在的JavaScript

    traceur转码(编译)器 Babel转码(编译)器 JavaScript API 的核心组成部分:ECMASCcript, DOM, BOM 桌面应用:electron 移动应用:Apache C ...

  2. 【LeetCode】365.水壶问题

    题目描述 解题思路 思路一:裴蜀定理-数学法 由题意,每次操作只会让桶里的水总量增加x或y,或者减少x或y,即会给水的总量带来x或y的变化量,转为数字描述即为:找到一对整数a,b使得下式成立: ax+ ...

  3. 执行py文件需要可执行权限吗?

    案例解析 这个问题描述起来有点违反直觉,要执行一个文件难道不应该需要可执行权限吗?让我们先来看一个例子: # module1.py def test(): print ('hello world!') ...

  4. 深入剖析setState同步异步机制

    关于 setState setState 的更新是同步还是异步,一直是人们津津乐道的话题.不过,实际上如果我们需要用到更新后的状态值,并不需要强依赖其同步/异步更新机制.在类组件中,我们可以通过thi ...

  5. ctfshow—web—web签到题

    打开靶机,发现只有一句话 查看源码 发现一段字符串,猜是base64加密 拿到flag

  6. zabbix-server安装部署配置

    zabbix-server安装部署配置 zabbixLinux安装部署安装脚本 1 一步一步部署 1.1 安装zabbix仓库源 这里安装阿里的zabbix仓库地址 选用zabbix版本3.4 rpm ...

  7. Vijos-P1103题解【线段树】

    本文为原创,转载请注明:http://www.cnblogs.com/kylewilson/ 题目出处: https://www.vijos.org/p/1103 题目描述: 一条马路从数轴0到L,每 ...

  8. kaggle新手如何在平台学习大神的代码

    原创:数据臭皮匠  [导读]Kaggle ,作为听说它很牛X但从未接触过的同学,可能仅仅了解这是一个参加数据挖掘比赛的网站,殊不知Kaggle也会有赛题相关的数据集, 比如我们熟知的房价预测.泰坦尼克 ...

  9. Java多线程基础知识笔记(持续更新)

    多线程基础知识笔记 一.线程 1.基本概念 程序(program):是为完成特定任务.用某种语言编写的一组指令的集合.即指一段静态的代码,静态对象. 进程(process):是程序的一次执行过程,或是 ...

  10. windows上传ipa到苹果开发者中(app store)的方法

    假如你已经使用过苹果开发者中心上架app,你肯定知道在苹果开发者中心的web界面,无法直接提交ipa文件,而是需要使用第三方工具,将ipa文件上传到构建版本,开发者中心才能在构建版本里选择构建版本上架 ...