UCF Practice Local Contest 2018 (practice)Rummy Score (dfs)
dfs,对于每个点数的牌,都有:不出、作为同花出、作为顺子出这三种选择
#include<bits/stdc++.h> using namespace std; int a[20],x,anss=0x3f3f3f3f; void dfs(int k) { if(k>13) { int sum=0; for(int i=1;i<=13;i++) { sum+=a[i]*i; } anss=min(anss,sum); return; } if(a[k]==0) { return dfs(k+1); } if(a[k]>=3) //同花 { for(int i=3;i<=a[k];i++) { a[k]-=i; dfs(k); a[k]+=i; } } int t=0; for(int i=k;i<=13;i++) { if(a[i]==0) break; else t++; if(t>=3) //顺子 { for(int j=k;j<=i;j++) { a[j]--; } dfs(k); for(int j=k;j<=i;j++) { a[j]++; } } } dfs(k+1); //不出 } int main() { for(int i=1;i<=7;i++) { cin>>x; a[x]++; } dfs(1); cout<<anss<<endl; }
相关知识
UCF Practice Local Contest 2018 (practice)Rummy Score (dfs)
practice是什么意思
ACT科学Session1生物(Practice实战练习)
花卉实习(Flower practice).doc
【Original in Practice】Dandelion planting, preservation and processing
巴赫花卉疗法作为医疗保健中的补充疗法:范围审查,Holistic Nursing Practice
解决食物过敏的健康公平问题,The Journal of Allergy and Clinical Immunology: In Practice
新农科背景下植物学课程教学方法改革与实践 Reform and Practice of Botany and Teaching Method under the Background of New Agricultural Science
口腔生理学术语V
Design and practice of a platform for monitoring, early
网址: UCF Practice Local Contest 2018 (practice)Rummy Score (dfs) https://www.huajiangbk.com/newsview2215624.html
上一篇: 沪教牛津版初中英语(八年级上册) |
下一篇: 习养相关的词语 习养相关的词语是 |
推荐分享

- 1君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039