POJ1671 Rhyme Schemes
| Time Limit: 1000MS | Memory Limit: 10000K | |||
| Total Submissions: 1776 | Accepted: 984 | Special Judge | ||
Description
Then spies of all factions will want 'em
Our codes will all fail
And they'll read our email
`Til we've crypto that's quantum and daunt 'em
Jennifer and Peter Shor (http://www.research.att.com/~shor/notapoet.html)
Has a rhyme scheme of aabba, indicating that the first, second and fifth lines rhyme and the third and fourth lines rhyme.
For a poem or stanza of four lines, there are 15 possible rhyme schemes:
aaaa, aaab, aaba, aabb, aabc, abaa, abab, abac, abba, abbb, abbc, abca, a bcb, abcc, and abcd.
Write a program to compute the number of rhyme schemes for a poem or stanza of N lines where N is an input value.
Input
will consist of a sequence of integers N, one per line, ending with a 0
(zero) to indicate the end of the data. N is the number of lines in a
poem.
Output
each input integer N, your program should output the value of N,
followed by a space, followed by the number of rhyme schemes for a poem
with N lines as a decimal integer with at least 12 correct significant
digits (use double precision floating point for your computations).
Sample Input
1
2
3
4
20
30
10
0
Sample Output
1 1
2 2
3 5
4 15
20 51724158235372
30 846749014511809120000000
10 115975
Source
按照题目所说,double的精度就可以过
第二类Stirling数:将n个不同的元素分成m个集合的问题。
度娘百科:http://baike.baidu.com/link?url=Gf9ql9PnQNNjCZVUgI6SH_o1DgFwpL5yOFalDr_baNqKmrr0unKZvaDNU5RzSGmMQIbKW3Efivp0GPOlz3tcga
别人简洁的题解:http://blog.csdn.net/nvfumayx/article/details/12356847
/**/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double f[][];//[元素数量][分组数量]=方法数
int n;
void init(){
int i,j;
for(i=;i<=;i++) f[][i]=,f[i][]=;
for(i=;i<=;i++)
for(j=;j<=i;j++){
f[i][j]=f[i-][j-]+f[i-][j]*j;
}
return;
}
int main(){
init();
while(scanf("%d",&n) && n){
double ans=;
for(int i=;i<=n;i++)ans+=f[n][i];
printf("%d %.0f\n",n,ans);
}
return ;
}
POJ1671 Rhyme Schemes的更多相关文章
- 2019上海网络赛 F. Rhyme scheme 普通dp
Rhyme scheme Problem Describe A rhyme scheme is the pattern of rhymes at the end of each line of a p ...
- 别人整理的DP大全(转)
动态规划 动态规划 容易: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...
- dp题目列表
此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...
- poj 动态规划题目列表及总结
此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 11 ...
- [转] POJ DP问题
列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...
- poj动态规划列表
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 13 ...
- POJ动态规划题目列表
列表一:经典题目题号:容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1191,1208, 1276, 13 ...
- POJ 动态规划题目列表
]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
随机推荐
- vue项目跨域问题
跨域 了解同源政策:所谓"同源"指的是"三个相同". 协议相同 域名相同 端口相同 解决跨域 jsonp 缺点:只能get请求 ,需要修改B网站的代码 cors ...
- 洛谷 3567/BZOJ 3524 Couriers
3524: [Poi2014]Couriers Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 2895 Solved: 1189[Submit][S ...
- Spring Cloud学习介绍
最近在学spring cloud, 整理了下 简单知识要求: 1.要了解springboot 2.了解分布式架构 3.了解微服务 4.了解springcloud是做什么的 带着这些,初学者 就至少有个 ...
- PHP获取接下来一周的日期
//获取接下来一周的日期 function GetWeeks() { $i=0; $weeks=[]; for ($i;$i<=7;$i++){ $month=date('m',time()+8 ...
- centos 关闭AliYunDun
执行命令: service aegis stop #停止服务 chkconfig --del aegis # 删除服务
- 14.VUE学习之-v-if v-else-if语法在网站注册中的实际应用讲解
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- Union found
Use array. class UnionFound { public: vector<int> v; int cnt; UnionFound(int n) { v = vector&l ...
- 最短路径:HDU2006-一个人的旅行(多个起点,多个终点)
题目: 一个人的旅行 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- Android四大组件之服务
创建一个服务,并与活动绑定 作为安卓四大组件之一的服务,毫无例外也要在manifast中进行注册 新建服务类继承于Service,并覆盖onBind( )方法,用于与活动绑定 public class ...
- 安装Mysql community server遇到计算机中丢失msvcr120.dll
一.下载community server版本 Mysql community server版本:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7 ...