博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj3226
阅读量:7078 次
发布时间:2019-06-28

本文共 1133 字,大约阅读时间需要 3 分钟。

高精度组合数学

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

你可能感兴趣的文章
WLC和汇聚交换机的配置
查看>>
使用python-gitlab的API V4来批量创建projects
查看>>
CLR.Via第三版第二章 生成、打包、部署和管理i应用程序及类型(
查看>>
关于ha高可用性的安装,ClusterIP和tomcat的配置
查看>>
我的系统我做主-----深度裁剪红帽5.8系统过程演示(只有5M哦)
查看>>
Java -- 多线程
查看>>
linux 配置 直接用VIM默认打开文件
查看>>
ftp 500 OOPS: could not bind listening IPv4 socket
查看>>
Zend server最大化应用程序的性能、扩展性和可用性
查看>>
Mac OSX操作系统安装和配置Zend Server 6教程(4)
查看>>
python进阶学习路线(全)
查看>>
浏览器加载与渲染
查看>>
HTTP常见错误返回代码
查看>>
安装homeassistant+python3.6
查看>>
老李分享:JDK,JRE,JVM区别与联系 1
查看>>
CentOS 7 上systemctl 的用法
查看>>
Android Design框架
查看>>
[Linux] 在 Linux CLI 使用 ssh-keygen 生成 RSA 密钥
查看>>
在 Ubuntu 16.04 Server 上安装 Zabbix
查看>>
Netgear wndr3700v2 路由器刷OpenWrt打造全能服务器(九)ftp服务
查看>>