cf 363A B C
A水题 ~~ 注意0输出
/*************************************************************************
> Author: xlc2845 > Mail: xlc2845@gmail.com
> Created Time: 2013年11月10日 星期日 19时35分23秒
************************************************************************/ #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cstdlib>
#define N 35
#define M 1000000007 using namespace std;
char a[15][10] =
{
"O-|-OOOO",
"O-|O-OOO",
"O-|OO-OO",
"O-|OOO-O",
"O-|OOOO-",
"-O|-OOOO",
"-O|O-OOO",
"-O|OO-OO",
"-O|OOO-O",
"-O|OOOO-"
};
int main()
{
int n;
scanf("%d",&n);
if(n == 0)
puts(a[0]);
while(n)
{
puts(a[n%10]);
n /= 10;
}
return 0;
}
B 用一个sum数组就可以了
/*************************************************************************
> Author: xlc2845 > Mail: xlc2845@gmail.com
> Created Time: 2013年11月10日 星期日 19时35分23秒
************************************************************************/ #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cstdlib>
#define N 150010
#define M 1000000007 using namespace std;
int high[N] = {};
int main()
{
int n, k, _min = M, _mini = 0;
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++)
{
scanf("%d",&high[i]);
high[i] += high[i-1];
}
for(int i = 0; i+k <= n; i++)
{
int sum = high[k+i] - high[i];
if(sum < _min)
{
_min = sum;
_mini = i+1;
}
}
printf("%d\n", _mini);
return 0;
}
C 题 注意好细节
/*************************************************************************
> Author: xlc2845 > Mail: xlc2845@gmail.com
> Created Time: 2013年11月10日 星期日 19时35分23秒
************************************************************************/ #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cstdlib>
#define N 250010
#define M 1000000007 using namespace std;
char str[N];
bool flag[N];
int main()
{
memset(flag, true, sizeof(flag));
int ok = 0;
bool ca = false;
char now;
gets(str);
int len = strlen(str);
for(int i = 0; i < len; i++)
{
if(!ok)
{
ok = 1;
now = str[i];
}
else if(ok == 1)
{
if(str[i] == now && !ca)
{
ok++;
ca = true;
}
else if(str[i] == now && ca)
{
flag[i] = false;
}
else
{
now = str[i];
ca = false;
}
}
else if(ok == 2)
{
if(str[i] == now)
flag[i] = false;
else
{
now = str[i];
ok = 1;
}
}
}
for(int i = 0; i < len; i++)
{
if(flag[i]) putchar(str[i]);
}
return 0;
}
cf 363A B C的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
随机推荐
- 济南学习 Day 1 T2 am
死亡[问题描述]现在有M个位置可以打 sif,有N +1个人在排队等着打 sif.现在告诉你 个人每个人需要多长的时间打 sif,问你第N +1个人什么时候才能打 sif. (前N个人必须按照顺序来) ...
- Codevs 1097 校门外的树
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题目描述 Description 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米 ...
- Codevs 1078 ==Poj 1258 Agri-Net
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 53270 Accepted: 22140 Description D ...
- git 的使用(4)-git暂缓区工作区原理和修改删除等命令
文章转载自:http://blog.csdn.net/think2me/article/details/39056379 博主说未经本人允许,不得转载,那就不贴了,拷贝关键部分作备忘 1. 暂存区是G ...
- 命名空间 和 class_exist() 问题
#namespace_test_1.php <?php namespace namespace_test_1; class test { const NAMESPACE = 'namespace ...
- js 函数闭包内部返回函数体调用方法难点解答
今天在网上,看到一篇关于js函数难点的文章,js函数的一些难点.在那上面提了一下,关于js函数返回另一个函数的问题,并附上了一道面试题: var add = function(x){ var sum ...
- 笨办法学 Python (第三版)(转载)
笨办法学 Python (第三版) 原文地址:http://blog.sina.com.cn/s/blog_72b8298001019xg8.html 摘自https://learn-python ...
- 【译】Android系统简介—— Activity
续上一篇,继续介绍Android系统.上一篇: [译]Android系统简介 本文主要介绍构建Android应用的一些主要概念: Activity Activity是应用程序中一个单独的有UI的页面( ...
- MVC 5.0(or5.0↓) Ajax.BeginForm 异步上传附件问题,答案是不能的!
MVC 5.0(or5.0↓) Ajax.BeginForm 异步上传附件问题,答案是不能的! (请注意我这里说的异步!) 来看一下下面这段一步提交file的代码 //前台 .cshtml 文件 & ...
- ios上取得设备唯一标志的解决方案
iOS 7中苹果再一次无情的封杀mac地址,现在已经不能获取ios7设备的物理地址.那么在开发中如何才能标识设备的唯一性呢?apple公司提供的方法是通过keychain来存一些标志信息,然后通过存的 ...