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 ...
随机推荐
- ACM-ICPC 2018 焦作赛区网络预赛G Give Candies(隔板定理 + 小费马定理 + 大数取模,组合数求和)题解
题意:给你n个东西,叫你把n分成任意段,这样的分法有几种(例如3:1 1 1,1 2,2 1,3 :所以3共有4种),n最多有1e5位,答案取模p = 1e9+7 思路:就是往n个东西中间插任意个板子 ...
- 【第十五章】 springboot + pojo默认值设置
我们有时需要给POJO设置默认值 pojo设置(推荐) 1.User package com.xxx.firstboot.domain; import lombok.Getter; import lo ...
- C#用Linq查询Combox的数据源
https://www.cnblogs.com/sufei/archive/2010/01/12/1645763.html var result = ((DataTable) (this.ComSh ...
- [Err] 1111 - Invalid use of group function
本文为博主原创,未经允许不得转载: 初衷,本想通过group by sql语句查询出不同id下总数在一定范围内的数据,所以产生如下的sql,及错误sql AND STATDATE < ' GRO ...
- css未知大小的图片居中
未知大小的图片在指定大小的div盒子中垂直水平居中: 无需要JS <style> .box { /*垂直居中*/ display: table-cell; vertical-align:m ...
- 01_Kafka概述
1.Kafka背景 * LinkedIn开发,2011年成为Apache的一个开源项目* 2012年,成为Apache的一个顶级项目* 基于java和Scala编写, 基于发布-订阅模型的消息系统(离 ...
- Gym - 100342J Triatrip (bitset求三元环个数)
https://vjudge.net/problem/Gym-100342J 题意:给出一个邻接矩阵有向图,求图中的三元环的个数. 思路: 利用bitset暴力求解,记得最后需要/3. #includ ...
- HDU 6125 Free from square(状态压缩+分组背包)
http://acm.hdu.edu.cn/showproblem.php?pid=6125 题意: 在${1,2,3,...n}$的数中选择1~k个数,使得它们的乘积不能被平方数整除(1除外),计算 ...
- java 编程技巧
1. 参数可空: @注解表示修改的字段可为空值.看它的定义,可以修饰在方法,参数和字段(类似c#中的?)上. @Target({ElementType.METHOD, ElementType.PARA ...
- shell 布尔运算符
布尔运算符 下表列出了常用的布尔运算符,假定变量 a 为 10,变量 b 为 20: 运算符 说明 举例 ! 非运算,表达式为 true 则返回 false,否则返回 true. [ ! false ...