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 ...
随机推荐
- Windows_7_休眠按钮没有了_如何找回?
1. 在运行中输入: powercfg -h on或者在命令行下输入: powercfg.exe /hibernate on注意:执行这个命令需要管理员权限. “休眠”回来了 2. 还是没 ...
- checking for tgetent()... configure: error: NOT FOUND!
今天centos出现了下面的异常: checking for tgetent()... configure: error: NOT FOUND! You need to install a termi ...
- UVa 11889 Benefit(数论)
题目链接: 传送门 Benefit Time Limit: 5000MS Memory Limit: 32768 KB Description Recently Yaghoub is play ...
- Mac配置一些开发环境(随时补充)
Mac安装mysql并启动 brew install mysql mysql.server start /usr/local/Cellar/mysql/5.6.10/support-files/mys ...
- 数据结构与算法分析 - 网络流入门(Network Flow)
转载:网络流基础篇--Edmond-Karp算法 BY纳米黑客 网络流的相关定义: 源点:有n个点,有m条有向边,有一个点很特殊,只出不进,叫做源点. 汇点:另一个点也很特殊, ...
- 【Alpha阶段】第十次Scrum例会
会议信息 挺过编译ddl,开始Alpha阶段最后的调试 时间:2016.11.08 21:30 时长:25min 地点:大运村1公寓5楼 类型:日常会议 NXT:2016.11.10 21:30 个人 ...
- Linux 下解压大全
.tar 解包:tar xvf FileName.tar 或 tar zxvf FilenName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!) ...
- Codeforces Round #345 D. Image Preview(二分)
题目链接 题意:看一个图片需要1单位时间,如果是 w 需要翻转 b 时间,切换到相邻位置(往左或者往右)需要 a 时间,求T时间最多能看几张图片 从第一个开始向右走看若干个图片然后往如果往左走就不会再 ...
- HTTP,TCP/IP协议
本文转自cnblogs:http://www.cnblogs.com/xhwy/archive/2012/03/03/2378293.html 一.概述 1.1 TCP HTTP UDP: 都 ...
- JS-window对象集合
知识点表格截图: