刷了这套题  感触良多

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

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

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

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. Shogun网站上的关于主流机器学习工具包的比较

    Shogun网站上的关于主流机器学习工具包的比较: http://www.shogun-toolbox.org/page/features/   created last updated main l ...

  2. oracle 删除旧的归档文件或跟踪文件

    2016-02-16 可以使用两种方法完成删除旧文件的操作: 一.是使用find命令结合-exec rm; 二.是使用find命令结合使用xargs rm. 例如: 把5天之前的归档文件删除: [or ...

  3. 批量删除wps文档里的回车符的方法!WPS使用技巧分享!

    有时候整理文档的时候,如果是从网上复制的文字,可能会因为复制而产生很多的回车符.怎样能批量去掉这些个回车符呢,下面马上告诉你批量删除wps文档里的回车符的方法!WPS使用技巧分享! 想要批量删除批量删 ...

  4. 关于jq+devexpress基础知识总结(随便的基础)

    //获取某行某列的值 onSelectionChanged: function (selectedItems) { ]; if (data != null) postionno = data.POST ...

  5. 【SSM 4】Mybatis逆向生成工具

    在上一篇博客中说到,Mybatis是灵活的SQL语句应用,不想Hibernate一样有其封装好的方法,那么,当我们用Mybatis的时候(Hibernate),我们都需要编写其实体类,和配置文件.本篇 ...

  6. appstore不能登陆

    Happened same with me. This is happening because the App Store is looking for a working connection o ...

  7. vs2010 sql server 2008数据库管理界面安装

    http://jingyan.baidu.com/article/1e5468f928e106484961b7b0.html

  8. vbox 不识别u盘的问题

    usb设备 ->启用usb设备 ->启用usb2.0(ehci)控制器 添加usb筛选器 给筛选器起个名字

  9. CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 解决方案

    1 设置c:windows\temp 目录访问权限 temp--> 属性-->安全-- > 添加network service -->并赋予其权限为 读 和 写--> 确 ...

  10. win10无法使用内置管理员账户打开应用怎么办

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System \UIPI 右边有个默认的项.将它的值改成1