刷了这套题  感触良多

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

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

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

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. CString std::string相互转换

    CString->std::string 例子: CString strMfc=“test“; std::string strStl; strStl=strMfc.GetBuffer(0); s ...

  2. (转)Silverlight 与 JS交互

    转自 http://www.cnblogs.com/wt616/archive/2011/10/08/2201987.html 1.Silverlight直接调用JS的函数: 这个很简单,只要在HTM ...

  3. 1、win32创建窗口函数(windows程序内部运行机制)

    利用win32创建窗口函数,主要操作步骤为: 1.设计一个窗口类 2.注册窗口类 3.创建窗口 4.显示及窗口更新 5.消息循环 6.窗口过程函数   (1)设计一个窗口类 设计窗口类,这样的类型已经 ...

  4. onethink连接操作 sqlite 数据库

    直接上干货:一个简单的demo onthink本身已经有sqlite数据库的驱动 不需要在下载 common下面的config文件: 'SQLITE'=> array( 'DB_TYPE' =& ...

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

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

  6. JQUERY DIALOG窗格内不能使用FORM

    今天在做AJAX DIALOG数据提交实验,实验目的是,在DIALOG内显示另一页面,并将FORM组件信息提交保存至数据库.代码如下: DIALOG实现: function OpenDialog(ur ...

  7. CString转string

    如题,找了半天... //CString转string USES_CONVERSION; CString temp; temp = _T("kjdsaflkjdlfkj"); ch ...

  8. 查找jsp页面报错技巧

    在报错跳转页面打印错误信息<div>系统执行发生错误,信息描述如下:</div> <div>错误状态代码是:${pageContext.errorData.stat ...

  9. 43、哈工大NLP自然语言处理,LTP4j的测试+还是测试

    1.首先需要构建自然语言处理的LTP的框架 (1)需要下载LTP的源码包即c++程序(https://github.com/HIT-SCIR/ltp)下载完解压缩之后的文件为ltp-master (2 ...

  10. UNDO内存结构剖析

    UNDO内存结构剖析 一.场景 Oracle的 C事物从早上9:00开始读取A表全部10w行数据,这个而读取需要经历5分钟.在9:01的时候,B事物将A表删除100条记录,那么,当9:05的时候,事物 ...