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

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

最近码力略渣,敲题总是WA,考虑不全,还是要加强码力
本题是一道组合数学统计问题
问的是给一个序列,求他在所有波浪序列中排名第几
注意各种限制,各种特判.....
#include 
#include
#include
typedef long long ll;using namespace std;char s[1000];ll dp[10][20][2];int tot,a[20];ll solve(int f,int llen,int dir){ int i; ll ans=1; for(i=2;i<=18-llen;i++) ans+=dp[f][i][dir]; return ans;}ll dfs(int pos,int doing){ if(pos==tot)return 0; ll ans=0,i; if(pos>=2)ans++; if(pos==0){ for(i=1;i
a[pos-1])ans+=solve(i,pos,1); else ans+=solve(i,pos,0); ans--; } } else if(pos>=2){ if(doing==0) i=a[pos-1]+1;else i=1; for(;i
a[pos])next=0; else next=1; return ans+=dfs(pos+1,next);}void init(){ int i,j,len; memset(dp,0,sizeof(dp)); for(i=1;i<9;i++) dp[i][2][0]=9-i; for(i=2;i<=9;i++) dp[i][2][1]=i-1; for(len=3;len<=18;len++){ for(i=1;i<9;i++){ for(j=i+1;j<=9;j++) dp[i][len][0]+=dp[j][len-1][1]; } for(i=2;i<=9;i++){ for(j=1;j

 

转载地址:http://usiel.baihongyu.com/

你可能感兴趣的文章
Spring的bean管理--注解和配置文件混合使用
查看>>
-save-dev 与 -save的区别
查看>>
TypeError: $(…).tooltip is not a function
查看>>
php count()函数用法 及其 一个坑
查看>>
Qt可扩展窗口实现
查看>>
JS自学笔记04
查看>>
MySQL基础
查看>>
写操作系统学到
查看>>
真正统治世界的十大算法
查看>>
FZU-2236 第十四个目标(树状数组)
查看>>
hibernate多表关联(<hibernate-mapping>)的配置
查看>>
07 Django 模板
查看>>
Redis的简介、启动、停止
查看>>
Jmeter性能测试 入门
查看>>
CSS_圣杯
查看>>
宜信敏捷数据中台建设实践|分享实录
查看>>
如何抓准问题?
查看>>
Office 365 On MacOS 系列——配置浏览器账号同时管理多个订阅
查看>>
先考学历还是先提升能力?
查看>>
openstack云计算实践-老男孩架构师课程教案笔记分享
查看>>