当前位置: 首页 > news >正文

poj3226

高精度组合数学

ContractedBlock.gif ExpandedBlockStart.gif View Code
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
public static void main(String[] args) throws FileNotFoundException
{
Scanner cin = new Scanner(new BufferedInputStream(System.in));
//Scanner cin = new Scanner(new FileInputStream("t.txt"));
int n = cin.nextInt();
while (n != 0)
{
String st = cin.next();
BigInteger a = new BigInteger("1");
BigInteger ans = new BigInteger("0");
int[] f = new int[30];
for (int i = 0; i < n; i++)
f[i] = st.charAt(i) - 'A';
for (int i = n - 1; i >= 0; i--)
{
int x = 0;
for (int j = 0; j < i; j++)
if (f[j] < f[i])
x++;
f[i] -= x;
}
for (int i = n - 1; i >= 0; i--)
{
int x = f[i];
ans = ans.add(BigInteger.valueOf(x).multiply(a));
a = a.multiply(BigInteger.valueOf(26 - i));
}
System.out.println(ans);
n = cin.nextInt();
}
}
}

转载于:https://www.cnblogs.com/rainydays/archive/2011/10/13/2210169.html

相关文章:

  • 简单使用ubuntu
  • 清除Windows Server Backup 备份副本
  • IT行业发展前景
  • [C++]运行时,如何确保一个对象是只读的
  • PowerShell应用之-批量执行SQL脚本
  • 大家都为了考试的事,读疯了。
  • 职场加薪步步高升的五大法则
  • DR模型集群概述
  • MVC LINQ中用封装的TSQL通用更新方法
  • htons htonl ntohl ntohs 的区别和作用
  • node.js 初体验
  • Oracle中账户被锁定的解决方法
  • 增删主键及修改表名
  • 2011.11.6
  • Control 'XXXX' accessed from a thread other than the thread it was created on
  • Apache的80端口被占用以及访问时报错403
  • Joomla 2.x, 3.x useful code cheatsheet
  • js写一个简单的选项卡
  • ng6--错误信息小结(持续更新)
  • PhantomJS 安装
  • React-生命周期杂记
  • tensorflow学习笔记3——MNIST应用篇
  • Vue组件定义
  • 笨办法学C 练习34:动态数组
  • 诡异!React stopPropagation失灵
  • 基于Mobx的多页面小程序的全局共享状态管理实践
  • 前端面试总结(at, md)
  • 通信类
  • 小程序button引导用户授权
  • 小程序测试方案初探
  • 机器人开始自主学习,是人类福祉,还是定时炸弹? ...
  • 进程与线程(三)——进程/线程间通信
  • 正则表达式-基础知识Review
  • ​ 全球云科技基础设施:亚马逊云科技的海外服务器网络如何演进
  • ​卜东波研究员:高观点下的少儿计算思维
  • #每日一题合集#牛客JZ23-JZ33
  • $.ajax中的eval及dataType
  • $.proxy和$.extend
  • (3)Dubbo启动时qos-server can not bind localhost22222错误解决
  • (附源码)ssm基于web技术的医务志愿者管理系统 毕业设计 100910
  • (附源码)ssm失物招领系统 毕业设计 182317
  • (黑客游戏)HackTheGame1.21 过关攻略
  • (四)搭建容器云管理平台笔记—安装ETCD(不使用证书)
  • (原創) 物件導向與老子思想 (OO)
  • .net core 3.0 linux,.NET Core 3.0 的新增功能
  • .Net Core/.Net6/.Net8 ,启动配置/Program.cs 配置
  • .net企业级架构实战之7——Spring.net整合Asp.net mvc
  • @select 怎么写存储过程_你知道select语句和update语句分别是怎么执行的吗?
  • [20180129]bash显示path环境变量.txt
  • [Android]创建TabBar
  • [ASP.NET MVC]Ajax与CustomErrors的尴尬
  • [cogs2652]秘术「天文密葬法」
  • [C语言]——C语言常见概念(1)
  • [Editor]Unity Editor类常用方法
  • [G-CS-MR.PS02] 機巧之形2: Ruler Circle