刷了这套题  感触良多

我想 感觉上的差一点就是差很多吧 。

每次都差一点  就是差很多了。。。

不能气馁。。要更加努力去填补那一点点。  老天不是在造物弄人,而是希望你用更好的自己去迎接自己。

A. Alyona and copybooks

有n本书  还需要买k本使得(n+k)%4==0

有三种  一本 a元  两本 b元  三本 c元的 不能分开卖

问至少花多少

枚举一下即可  。。。 我居然一开始搞了个dp记录买1-4本的最优策略....还wa了....

#include <stdio.h>
#include <iostream>
#include <algorithm>
//#include <>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 2e5+;
ll v[];
int main()
{
int n;
cin>>n;
for(int i=;i<=;i++)
cin>>v[i];
ll ans = LONG_LONG_MAX;
for(int i=;i<=;i++)
for(int j=;j<=;j++)
for(int k=;k<=;k++)
{
if((n+i+j*+k*)%==)
{
ans = min(ans,i*v[]+j*v[]+k*v[]);
}
}
cout<<ans<<endl;
return ;
}

AC代码

B. Alyona and flowers

给你m个区间  问选任意的区间使得和最大

发现区间和为负不要选就好

#include <stdio.h>
#include <iostream>
#include <algorithm>
//#include <>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 2e5+;
ll v[];
int main()
{
int n,k;
cin>>n>>k;
for(int i=;i<=n;i++)
{ cin>>v[i];
v[i]+=v[i-];
}
ll ans = ;
while(k--)
{
int x;int y;
cin>>x>>y;
ll val = v[y] - v[x-];
if(val>) ans+=val;
}
cout<<ans<<endl;
return ;
}

AC代码

C. Alyona and mex

给你长度为n的序列和m个区间,为区间中没出现过的最小的非负整数最大是多少。

那么区间最短的那个决定ans

接下来我们按照

[0,ans-1]这样循环填充n个位置。这样的话在任意的区间内都有[0,ans-1]

这个很机智啊。。。。

#include <stdio.h>
#include <iostream>
#include <algorithm>
//#include <>
#include <vector>
using namespace std;
typedef long long ll; int main()
{
int n,k;
cin>>n>>k;
int ans = INT_MAX;
for(int i=;i<k;i++)
{
int x;int y;
cin>>x>>y;
if((y-x)<ans)
{
ans = y-x;
}
}
ans++;
cout<<ans<<endl;
for(int i=;i<n;i++)
{
printf("%d ",i%ans);
}
return ;
}

AC代码

D.倍增LCA

想一想  MK一下

Codeforces Round #381 (Div. 2) 复习倍增//的更多相关文章

  1. Codeforces Round #381 (Div. 2) D. Alyona and a tree 树上二分+前缀和思想

    题目链接: http://codeforces.com/contest/740/problem/D D. Alyona and a tree time limit per test2 secondsm ...

  2. Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置

    https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...

  3. Codeforces Round #381 (Div. 1) B. Alyona and a tree dfs序 二分 前缀和

    B. Alyona and a tree 题目连接: http://codeforces.com/contest/739/problem/B Description Alyona has a tree ...

  4. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

  5. Codeforces Round #381 (Div. 2) D dfs序+树状数组

    D. Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  6. Codeforces Round #381 (Div. 2) C. Alyona and mex(无语)

    题目链接 http://codeforces.com/contest/740/problem/C 题意:有一串数字,给你m个区间求每一个区间内不含有的最小的数,输出全部中最小的那个尽量使得这个最小值最 ...

  7. Codeforces Round #381(div 2)

    A.(分类讨论) 题意:你有n本书,有三种买书方案,花a元买1本,花b元买2本,花c元买3本,问最少花多少钱,使得你书的总数是4的倍数 分析:分类讨论的题,但是要注意你可以买超过4本书--可以买5本. ...

  8. Codeforces Round #381 (Div. 2) A B C 水 构造

    A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input stand ...

  9. Codeforces Round #381 (Div. 2)D. Alyona and a tree(树+二分+dfs)

    D. Alyona and a tree Problem Description: Alyona has a tree with n vertices. The root of the tree is ...

随机推荐

  1. Python体验(08)-图形界面之工具栏和状态栏

    # coding=utf-8 import wx # 导入必须的Python包 class MenuForm(wx.Frame): def OnQuit(self,event): self.Close ...

  2. ubuntu-利用pdnsd-TCP方式获取IP-拒绝DNS污染

    那,自从国内技术出现了DNS污染问题呢,时常导致很多国外网站访问不正常,所以通过参考一些博客所属避免DNS污染的方法,决定搭建一个Ubuntu JeOS下的DNS缓存服务器,该服务器利用TCP方式获取 ...

  3. pip UnicodeDecodeError: 'ascii' codec can't decode byte

    http://blog.csdn.net/computerms/article/details/48056103

  4. asp.net中的ListBox控件添加双击事件

    问题:在Aspx页里的ListBox A中添加双击事件,将选中项添加到另一个ListBox B中,双击ListBox B中的选中项,删除当前选中项 页面: <asp:ListBox ID=&qu ...

  5. Salesforce 使用Js 调用Webservice实例

    1,创建 Custom Button 在页面上 2, 创建CustomJs 代码调用Webservice <!--参数名区分大小写,对于跨层object直接在Object名后直接加参字段名即可- ...

  6. virt-manager管理整个云平台的instances

    http://people.redhat.com/~rjones/virt-top/faq.html

  7. MongoDB(四)mongodb设置用户访问权限

    我们知道MySQL在安装的时候需要我们设置一个数据库默认的用户名和密码,mongodb也不例外,不过mongodb是默认的没有设置访问限制的,不需要输入用户名和密码都可以访问的,但是这样会十分的不安全 ...

  8. css定位和浮动

    1.css中一切元素皆为框.div.p.h1等为块框:span.strong等为行内框,(在文本中每一行会被自动默认为行框,行框和行内框是不一样的概念).通过display可以改变框的类型,行内框通过 ...

  9. Android IOS WebRTC 音视频开发总结(八十七)-- WebRTC中丢包重传NACK实现分析

    本文主要介绍WebRTC中丢包重传NACK的实现,作者:weizhenwei ,文章最早发表在编风网,微信ID:befoio 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信ID ...

  10. web.xml常用元素配置

    tomcat服务器: tomcat是一个WEB服务器,所有的j2ee WEB程序可以在此处运行. tomcat服务器是一个符合j2ee标准的WEB服务器.则J2ee的EJB程序无法在此处运行. 如果要 ...