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 ...
随机推荐
- linux内核分析 第3章读书笔记
第三章 进程管理 一.进程 1.进程 进程就是处于执行期的程序. 进程就是正在执行的程序代码的实时结果. 进程是处于执行期的程序以及相关的资源的总称. 进程包括代码段和其他资源. 2.线程 执行线程, ...
- IDEA 插件-码云
插件安装 最新插件版本: 2018.3.1.(2019-01-10 发布)注意:码云 IDEA 插件已由 gitosc 更名为 gitee.新版插件 gitee 菜单已经和 git 菜单合并 通过「插 ...
- startActivityForResult( )用法
一.与startActivity( )的不同之处 1, startActivity( ) 仅仅是跳转到目标页面,若是想跳回当前页面,则必须再使用一次startActivity( ). 2, start ...
- 理解 python 中__name__ = '__main__' 的作用
很多新手刚开始学习python的时候经常会看到python 中__name__ = \'__main__\' 这样的代码,可能很多新手一开始学习的时候都比较疑惑,python 中__name__ = ...
- [loss]Triphard loss优雅的写法
之前一直自己手写各种triphard,triplet损失函数, 写的比较暴力,然后今天一个学长给我在github上看了一个别人的triphard的写法,一开始没看懂,用的pytorch函数没怎么见过, ...
- Ubuntu 14.04 python3.6 安装
参考 how-do-i-install-python-3-6-using-apt-get Ubuntu 14.04 python3.6 安装 sudo add-apt-repository ppa:j ...
- 2、Python快速入门(0529)
要素7:输入/输出 1.python解释器提供了3种标准文件对象,分别为标准输入.标准输出和标准错误,它们在sys模块中分别以sys.stdin.sys.stdout和sys.stderr形式提供: ...
- Selenium UI自动化测试 Selenium Automatic Testing
https://www.cnblogs.com/sunada2005/archive/2013/12/22/3486314.html UI Automatic Testing 1. 什么样的项目适合自 ...
- 《剑指offer》第三十题(包含min函数的栈)
// 面试题30:包含min函数的栈 // 题目:定义栈的数据结构,请在该类型中实现一个能够得到栈的最小元素的min // 函数.在该栈中,调用min.push及pop的时间复杂度都是O(1). #i ...
- 《剑指offer》第十六题(数值的整数次方)
// 面试题:数值的整数次方 // 题目:实现函数double Power(double base, int exponent),求base的exponent // 次方.不得使用库函数,同时不需要考 ...