Luogu 1087 FBI tree

#include <cstdio>
#include <cstring> char s[4100];
int n; char fbi(int l, int r) {
bool f0=false, f1=0;
for (int k=l; k<r; k++){
if (s[k]=='0') f0=true; else f1=true;
if (f0 && f1) return 'F';
}
if (f0) return 'B'; return 'I';
}
void dfs(int l, int r) {
if (r-l>1){
int p=l+(r-l)/2;
dfs(l, p), dfs(p, r);
}
putchar(fbi(l,r));
}
int main() {
scanf("%d", &n); scanf("%s", s);
dfs(0, strlen(s));
return 0;
}

Bzoj 1635 [Usaco2007 JAN] Tallest Cow

#include <cstdio>
#include <cstring>
#define max(A, B) ((A)>(B)?(A):(B))
#define min(A, B) ((A)<(B)?(A):(B)) int n, I, H, R, t;
int f[10005];
bool v[10005][10005]; int main() {
scanf("%d%d%d%d", &n, &I, &H, &R);
for (int i=1; i<=n; ++i) f[i]=H;
while (R--) {
register int a, b;
scanf("%d%d", &a, &b);
register int x=min(a, b), y=max(a, b);
if (v[x][y]) continue; v[x][y]=true;
for (int i=x+1; i<y; ++i) --f[i];
}
for (int i=1; i<=n; ++i) printf("%d\n", f[i]);
return 0;
}

Bzoj 1621 [Usaco2008 Open] Roads Around The Farm

#include <cstdio>

int cnt, n, k;

void dfs(int x) {
if (x<=k || (x-k)&1) ++cnt; else dfs(x-k>>1), dfs(x+k>>1);
} int main() {
scanf("%d%d", &n, &k);
dfs(n);
printf("%d\n", cnt);
return 0;
}

Bzoj 1088 [SCOI2005] Mine

#include <cstdio>
#include <cstring> int n, d[10005], p[10005], ans; inline bool chk() {
for (int i=2; i<=n; ++i) p[i+1]=d[i]-p[i-1]-p[i];
return !p[n+1];
} int main() {
scanf("%d", &n);
memset(p, -1, sizeof p);
for (int i=1; i<=n; ++i) scanf("%d", &d[i]);
for (int i=0; i<=d[1]; ++i) {
memset(p, 0, sizeof p);
p[1]=i, p[2]=d[1]-i;
if (chk()) ++ans;
}
printf("%d\n", ans);
return 0;
}
  • [ ] Bzoj 1028

CSP-S2 Review: 模拟的更多相关文章

  1. CSP复赛day2模拟题

    没错,我又爆零了.....先让我自闭一分钟.....so 当你忘记努力的时候,现实会用一记响亮的耳光告诉你东西南北在哪. 好了,现在重归正题: 全国信息学奥林匹克联赛(NOIP2014) 复赛模拟题 ...

  2. csp 201709-2 优先队列模拟

    数据规模: 用优先队列对各个事件的发生先后记录即可: #include<iostream> #include<queue> using namespace std; ]; st ...

  3. hdu1047(模拟大量的循环添加)

    标题信息:总结多个大整数,(使用add循环相加的功能) http://acm.hdu.edu.cn/showproblem.php? pid=1047 AC代码: /**  *大数的循环加法,转化为字 ...

  4. hdu1753()模拟大型实景数字相加

    标题信息: 手动求大的实数在一起, pid=1753">http://acm.hdu.edu.cn/showproblem.php?pid=1753 AC代码: /**  *大实数相加 ...

  5. 2018.9.5 Java中使用栈来模拟队列

    栈的规律是是先进后出 队列的规律是先进先出 栈模拟队列 首先我们定义两个栈,一个放数据,一个出数据,判断B栈是否有元素,有元素则直接pop:没有元素则需要我们将A里面的元素出栈然后放到B里面,再取出, ...

  6. 2019.10.26 CSP%您赛第三场

    \(CSP\)凉心模拟^_^ --题源\(lqx.lhc\)等各位蒟蒻 题目名称 比赛 传递消息 开关灯 源文件名 \(competition.cpp\) \(message.cpp\) \(ligh ...

  7. NOIP模拟83(多校16)

    前言 CSP之后第一次模拟赛,感觉考的一般. 不得不吐槽多校联测 OJ 上的评测机是真的慢... T1 树上的数 解题思路 感觉自己思维有些固化了,一看题目就感觉是线段树. 考完之后才想起来这玩意直接 ...

  8. hdu1316(大数的斐波那契数)

    题目信息:求两个大数之间的斐波那契数的个数(C++/JAVA) pid=1316">http://acm.hdu.edu.cn/showproblem.php? pid=1316 这里 ...

  9. (NOIP)CSP-S 2019前计划

    前言 无 1.NOIP原题板刷 NOIP原题板刷 这是一篇咕了的blog 2.牛客 & ACwing & 洛谷 网课学习 收获还是蛮大的,不过我没有写博客 3.codeforces专项 ...

随机推荐

  1. mac键盘在ubuntu下开启fn功能按键

    转载:http://wiki.ubuntu.org.cn/UbuntuHelp:AppleKeyboard Change Function Key behavior This section of t ...

  2. Python 入门之Python基础知识

    Python 入门之Python基础知识 1.变量 (1)变量就是把程序运行的中间结果临时存在内存中,以便后续代码使用 (2)变量的作用: 昵称,就是代指内存中某个地址中的内容 a = 123 变量名 ...

  3. 数塔 Easy

    在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?  已经告诉你了,这是个DP的题 ...

  4. N皇后问题(递归)

    //八皇后递归解法 //#include<iostream> //using namespace std; #include<stdio.h> ] = {-,-,-,-,-,- ...

  5. tabcontrol动态生成选项卡,并且在选项卡中添加窗体

    http://blog.csdn.net/zx13525079024/article/details/6084733 今天在论坛上看到有人问到,如果在点击TRVEVIEW时动态生成tabcontrol ...

  6. Mac 切换bash zsh等shell

    现在假设大家都安装了iTerm2,我们先把bash切换成zsh,使用命令行如下: chsh -s /bin/zsh 执行命令后,会让你输入电脑的密码,输入即可.完成后,需要完全退出iTerm2,再次进 ...

  7. luogu P1398 [NOI2013]书法家

    传送门 注意到\(N\ O\ I\)三个字母都可以从左到右拆成三部分,即\(N=\)一个矩形+一堆矩形+一个矩形,\(O=\)一条+两条横的+一条,\(I=\)两条横的+一个矩形+两条横的,所以可以拆 ...

  8. 更改导航栏的背景和文字Color

    更改导航栏的背景和文字Color方法一: [objc] view plaincopy//set NavigationBar 背景颜色&title 颜色  [self.navigationCon ...

  9. Result window is too large, from + size must be less than or equal to: [10000] but was [78440]. See the scroll api for a more efficient way to request large data sets

    {"error":{"root_cause":[{"type":"query_phase_execution_exception& ...

  10. 15.Linux-CentOS系统重启网卡ping不通问题(云环境)

    问题: CentOS系统网络不通,重启网卡后能ping通,等一会就又不通. 解决: 在云环境管理平台下,KVM系统的MAC地址,使其重新生成一下.