UVALive 4174
DES:给出一个字符串。连续空格的个数代表一个新的字符。奇数个表示0。偶数个表示1。然后根据这个码作为ASCII码。写出对应的字符。就是统计空格个数。二进制转换成十进制的小模拟。但是比赛的时候敲得很不顺。
#include<stdio.h>
#include<string.h>
#include<map>
#include<vector>
#include<math.h>
#include<iostream>
#include<map>
using namespace std; char str[];
int num[];
char anss[];
int cou;
int tt; void change()
{
int temp = (cou % );
int ans = ;
tt = ;
char la;
for (int i=; i<temp; ++i)
{
num[cou++] = ;
}
for (int i=; i<cou; i+=)
{
int t = ;
ans = ;
for (int j=i; j<i+; ++j)
{
ans += pow(, t) * num[j];
t--;
}
if (ans >= && ans <= )
{
int hh = ans + int('A');
hh -= ;
la = char(hh);
}
else if (ans == ) la = '.';
else if (ans == ) la = '-';
else if (ans == ) la = ',';
else if (ans == ) la = '\'';
else if (ans == ) la = ' ';
else if (ans == ) la = '?';
anss[tt++] = la;
}
} int main()
{
cou = ;
while(gets(str))
{
int len = strlen(str);
int cnt = ;
if (str[] == '*')
{
change();
int st = ;
while(anss[st] == ' ')
st++;
int ed = tt-;
while(anss[ed] == ' ')
ed--;
for (int i=st; i<=ed; ++i)
{
cout << anss[i];
}
cout << endl;
memset(num, , sizeof(num));
memset(anss, , sizeof(anss));
cou = ;
continue;
}
if (str[] == '#')
break; for (int i=; i<len; ++i)
{
cnt = ;
if (str[i] == ' ')
{
int j;
for (j=i; ; j++)
{
if (str[j] != ' ')
break;
cnt++;
}
if (cnt % == ) num[cou++] = ;
else num[cou++] = ;
cnt = ;
i = j;
}
}
}
return ;
}
LOoK
UVALive 4174的更多相关文章
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- UVALive 6948 Jokewithpermutation dfs
题目链接:UVALive 6948 Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
随机推荐
- JAVA I/O(四)网络Socket和ServerSocket
<Thinking in Enterprise Java>中第一章描述了用Socket和Channel的网络编程,核心即为Socket和Channel,本文简单讲述Socket的应用. S ...
- Python3基础 ** 幂运算 // 整除运算
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 【maven】在IDEA上 使用maven进行打包时报错:Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.3:jar
报错内容如下: [INFO] ------------------------------------------------------------------------ [INFO] BUILD ...
- hash入门
如果你已经确保自己的hash技巧已经入门,那么请左转这篇博文 首先介绍一下hash? 事实上是一种叫做蛤丝的病毒 以下讲到的hash都是OI中最常用到的hash方法:进制哈希 做法: 首先设一个进制数 ...
- 论文笔记——DenseNet
<Densely Connected Convolutional Networks>阅读笔记 代码地址:https://github.com/liuzhuang13/DenseNet 首先 ...
- animate动画回调函数
对非动画的实现排队,比如这个css()是要放在回调函数里才能,让前面的动画执行完成后在进行实现 $('button').click(function(event) { $(this).next().a ...
- 【Python】【有趣的模块】【Bobo】
[python web框架之 bobo的安装配置] [Mac] 我的Mac环境,python3.5 1. 安装bobo : >>> pip3 install bobo 2. 配 ...
- shell while 语句
普通循环格式: while condition do command done 例子一 #!/bin/bash )) do echo $int let "int++" done 结 ...
- Windows 2003 server下载
http://www.downza.cn/soft/182837.html或http://www.imsdn.cn/operating-systems/windows-server-2003/
- django关系类型字段
一.多对一(ForeignKey) 多对一的关系,通常被称为外键.外键字段类的定义如下: class ForeignKey(to, on_delete, **options)[source] 外键需要 ...