POJ 1850 Code
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 7202 | Accepted: 3361 |
Description
The coding system works like this:
The words are arranged in the increasing order of their length.
The words with the same length are arranged in lexicographical order (the order from the dictionary).
We codify these words by their numbering, starting with a, as follows:
a - 1
b - 2
...
z - 26
ab - 27
...
az - 51
bc - 52
...
vwxyz - 83681
...
Specify for a given word if it can be codified according to this coding system. For the affirmative case specify its code.
Input
The word is maximum 10 letters length
The English alphabet has 26 characters.
Output
Sample Input
bf
Sample Output
55
Source
主要是这个公式。。。

然后就是关键了,长度为2的字符串,根据开头字母不同,就有25种不同情况,编程去处理是很困难的。这里必须要用数学方法去处理。


所以用一个简单的循环就能计算出 比str长度少的所有字符串个数 了,这就是数学的威力,把受限的取法转换为不限制的取法
|
#include <iostream>
#include <cstdio> #include <cstring> using namespace std; int c[30][30]; void Init() int main() int sum=0; |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
POJ 1850 Code的更多相关文章
- POJ 1850 Code(组合数)
http://poj.org/problem?id=1850 题意 :给定字符串,系统是用字符串组成的,字符串是按字典序排的.编码系统有三条规则,1这些的单词的长度是由小到大的,2相同长度的按字母在字 ...
- poj 1850 code(组合数学)
题目:http://poj.org/problem?id=1850 题意:按给定的规则给字母编号. 一个很简单的题目,但是却做了好久.................................. ...
- POJ 1850 Code(找规律)
Code Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7913 Accepted: 3709 Description ...
- POJ 1850 Code 字符串 难度:1
题意: 1 如果是严格升序的字母字符串,那么可以输出非0解码,否则不能译码输出0 2 字符串解码 遵循递增原则,其值为 到现在为止的所有按字母序小于该字符串的数量 + 1; #include < ...
- POJ - 1850 Code(组合数学)
https://vjudge.net/problem/POJ-1850 题意 输出某字符串在字典中的位置.字符串不合规则时输出0. 分析 首先判断字符串合法性,也就是判断是不是升序排列的.如果符合,以 ...
- poj:1850 Code(组合数学?数位dp!)
题目大意:字符的字典序依次递增才是合法的字符串,将字符串依次标号如:a-1 b-2 ... z-26 ab-27 bc-52. 为什么题解都是组合数学的...我觉得数位dp很好写啊(逃 f[pos][ ...
- 【POJ 1850】 Code
[POJ 1850] Code 还是非常想说 数位dp真的非常方便! !. 数位dp真的非常方便!.! 数位dp真的非常方便! !! 重要的事说三遍 该题转换规则跟进制差点儿相同 到z时进一位 如az ...
- POJ 1496 POJ 1850 组合计数
Code Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8256 Accepted: 3906 Description Tran ...
- POJ - 1850 B - Code
Transmitting and memorizing information is a task that requires different coding systems for the bes ...
随机推荐
- 使用convert来批量处理图片
这是个神奇的工具,居然使用命令行就可以这么方便的处理图片.功能有待挖掘. 这个是把图片批量进行 resize 的脚本. #!/bin/sh counter= root=mypict resolutio ...
- 让AutoMapper更好用
AutoMapper Dto与EF实体之间的转换用AutoMapper会变的很方便.很高效,是大多数项目的选择.博主本人的项目也在使用AutoMapper这个组件 好用归好用,但是想要把它用好又是另一 ...
- CentOS同步时间
用date查看系统当前时间,date -R 可查看时区. CentOS 同步时间由ntp服务提供,可以用"yum install ntp -y"安装. 装完后运行命令 ntpdat ...
- iOS - CALayer相关(CATransform3D)
一.图层的几何 图层的几何简单通俗,图层的所有几何属性(包括矩阵变换),都可以有隐式和显式动画. 图层几何的属性: 1.position是CGPoint值,她指定图层相对于她图层的位置,该值基于父图层 ...
- python BeautifulSoup4
source form http://www.bkjia.com/ASPjc/908009.html 昨天把传说中的BeautifulSoup4装上了,还没有装好的童鞋,请看本人的上一篇博客: Py ...
- glade2支持C++代码的输出(3)
今天完成了glade-2生成configure.ac/Makefile.am等调整 代码为:cpp_out_4.patch.zip BaseObject类也做了一些小的调整:BaseObject.00 ...
- Servlet Request的 getInputStream() getReader() getParameter()
如果你知道了这三者的区别,请忽略 最近碰到了servlet对入参获取方式的处理问题,因为二方库处理不当,导致了获取不到入参的情况,之前也知道这三个方法不兼容,现简单介绍下 1.这三个获取入参的方法,是 ...
- js014-表单脚本
js014-表单脚本 本章内容: 理解表单 文本框验证与交互 使用其他表单控制 14.1 表单的基础知识 在HTML中,表单时由<form>元素来表示的,在JS中,表单对应的时HTMLFo ...
- VIM for Python and Django Development
VIM for Python and Django Development VIM-PyDjango created by Programmer for Programmer who work on ...
- notification的使用
示例: NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); No ...