http://poj.org/problem?id=1850

题意 :给定字符串,系统是用字符串组成的,字符串是按字典序排的。编码系统有三条规则,1这些的单词的长度是由小到大的,2相同长度的按字母在字典序的顺序排的,3 a-1,b-2,.....z-26,ab-27,..........,az-51,bc-52,............,vwxyz - 83681,.................。输入的是长度不超过10的全为小写英语字母的字符串,让你输出对应的数字,如果并没有按照顺序,则输出0 。

思路 :http://hi.baidu.com/lxyzmnwvhokptur/item/18c806469a668fe31e19bc1a#0这大神里边写的很详细,可以好好看看。

#include <iostream>
#include <cstdio>
#include <math.h>
#include <string.h> using namespace std ; int com[][] = {};
char ch[] ; int main()
{
for(int i = ; i <= ; i++)
for(int j = ; j <= i ; j++)
if(!j || i == j)
com[i][j] = ;
else
com[i][j] = com[i-][j-]+com[i-][j] ;
com[][] = ;
while(~scanf("%s",ch))
{
for(int i = ; i < strlen(ch)- ; i++)
if(ch[i] > ch[i+])
{
printf("0\n") ;
return ;
}
int sum = ;
for(int i = ; i < strlen(ch) ; i++)
sum += com[][i] ;
for(int i = ; i < strlen(ch) ; i++)
{
char sh = (!i)?'a':ch[i-]+ ;
while(sh <= ch[i]-)
{
sum += com['z'-sh][strlen(ch)--i] ;
sh++ ;
}
}
printf("%d\n",sum+) ;
}
return ;
}

POJ 1850 Code(组合数)的更多相关文章

  1. poj 1850 code(组合数学)

    题目:http://poj.org/problem?id=1850 题意:按给定的规则给字母编号. 一个很简单的题目,但是却做了好久.................................. ...

  2. POJ 1850 Code

    组合数学.... Code Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7202 Accepted: 3361 Descrip ...

  3. POJ 1850 Code(找规律)

    Code Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7913   Accepted: 3709 Description ...

  4. POJ - 1850 Code(组合数学)

    https://vjudge.net/problem/POJ-1850 题意 输出某字符串在字典中的位置.字符串不合规则时输出0. 分析 首先判断字符串合法性,也就是判断是不是升序排列的.如果符合,以 ...

  5. POJ 1850 Code 字符串 难度:1

    题意: 1 如果是严格升序的字母字符串,那么可以输出非0解码,否则不能译码输出0 2 字符串解码 遵循递增原则,其值为 到现在为止的所有按字母序小于该字符串的数量 + 1; #include < ...

  6. poj:1850 Code(组合数学?数位dp!)

    题目大意:字符的字典序依次递增才是合法的字符串,将字符串依次标号如:a-1 b-2 ... z-26 ab-27 bc-52. 为什么题解都是组合数学的...我觉得数位dp很好写啊(逃 f[pos][ ...

  7. 【POJ 1850】 Code

    [POJ 1850] Code 还是非常想说 数位dp真的非常方便! !. 数位dp真的非常方便!.! 数位dp真的非常方便! !! 重要的事说三遍 该题转换规则跟进制差点儿相同 到z时进一位 如az ...

  8. POJ 1496 POJ 1850 组合计数

    Code Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8256 Accepted: 3906 Description Tran ...

  9. POJ - 1850 B - Code

    Transmitting and memorizing information is a task that requires different coding systems for the bes ...

随机推荐

  1. iOS - 文件操作(File Operating)

    1. 沙盒 & NSData /*_______________________________获取沙盒路径_________________________________________* ...

  2. 生成 网站“面包屑” XML

    using System; using System.Collections.Generic; using System.IO; using System.Threading; using Syste ...

  3. APC -- Asynchronous Procedure Call 异步过程调用

    异步过程调用(APC -- Asynchronous Procedure Call )是一种与常用的和简单的同步对象不同的一种同步机制. 我们在我们线程里使用基本的同步对象如MUTEX去通知其它线程, ...

  4. c#基础学习笔记-----------委托事件

    这里有一个比较简单的委托实例应用(跨窗体操作控件) http://blog.csdn.net/bdstjk/article/details/7004035 还有一个比较详细的介绍并深入理解委托事件的讲 ...

  5. js中的一些零碎方法

    ajax表单提交: $.post("do_login", f.serializeArray(), function(data) { if (data.status + " ...

  6. JavaScript jQuery 入门回顾 2

    JQuery 滑动 利用jQuery可以在元素上创建滑动效果. slideDown() 向下滑动元素. slideUp() 向上滑动元素. slideToggle() 在 slideDown() 与 ...

  7. RequireJS入门与进阶

    RequireJS由James Burke创建,他也是AMD规范的创始人. RequireJS会让你以不同于往常的方式去写JavaScript.你将不再使用script标签在HTML中引入JS文件,以 ...

  8. 【Delphi】无标题移动窗体

    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Inte ...

  9. phpcms v9修改栏目描述的多行文本为编辑器方法

    phpcms v9在添加栏目的时候,栏目描述为多行文本,无法满足有图片,以及格式的修改调整,那么仿站网今天告诉大家如何将他改为编辑器,方法如下 找到phpcms/moudles/admin/templ ...

  10. jquery 获取 CheckBox 的状态

    <td style="width:220px;vertical-align:central;"><input type="checkbox" ...