刷了这套题  感触良多

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

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

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

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. adcfgclone.pl appsTier报错Unable to locate 'linkxlC' utility in path

    $ cd /u01/dev/apps/apps_st/comn/clone/bin$ perl adcfgclone.pl  appsTier                     Copyrigh ...

  2. ORA-12520:TNS:监听程序无法为请求的服务器类型找到可用的处理程序

    连接数太多 关掉没用的 plsql

  3. 共享onload事件

    在做前端工作中,我们想要设置某个函数prepare,让它在网页加载完毕后执行,会触发一个onload事件,这个事件与windows对象相关联,必须把prepare函数绑定到这个时间上,语法如下:win ...

  4. Spark Streaming源码解读之Executor容错安全性

    本期内容 : Executor的WAL 消息重放 数据安全的角度来考虑整个Spark Streaming : 1. Spark Streaming会不断次序的接收数据并不断的产生Job ,不断的提交J ...

  5. SQL Server提高事务复制效率优化(一)总体概述

      随着公司业务的发展,数据量增长迅速,在解决Scale Out的同时,还要考虑到主从的复制延迟问题,尽量降到1s以内满足线上业务,如果不调整,SQL Server默认的配置可能平均要3s左右.生产的 ...

  6. JS操作JSON总结

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  7. SQL SERVER中求上月、本月和下月的第一天和最后一天 DATEADD DATEDIFF

    SQL SERVER中求上月.本月和下月的第一天和最后一天   1.上月的第一天 SELECT CONVERT(CHAR(10),DATEADD(month,-1,DATEADD(dd,-DAY(GE ...

  8. Hive集成HBase;安装pig

    Hive集成HBase 配置 将hive的lib/中的HBase.jar包用实际安装的Hbase的jar包替换掉 cd /opt/hive/lib/ ls hbase-0.94.2*  rm -rf ...

  9. tracert与pathping

    trace route(windows命令为tracert,Linux命令为traceroute)命令可以列出本地计算机与目标计算机之间所有经过的计算机信息.可以输入目标计算机的名字(如www.bai ...

  10. sql2008r2-vs2013安装下载

    vs2013链接:http://www.cnblogs.com/wuyepiaoxue/p/5661174.html sql2008r2链接:http://download.microsoft.com ...