当前位置:网站首页>2021-3-17-byte-hu Pai
2021-3-17-byte-hu Pai
2022-07-27 12:17:00 【Anethole job】
Title Description :
1. All in all 36 card , Each card is 1~9. Every number 4 card .
2. You have... In your hand 14 card , If this 14 Cards meet the following conditions , That is, it's a sum of cards
3.14 There's... In the cards 2 A card with the same number , It's called a bird's head .
4. Remove the above 2 card , be left over 12 Cards can make up 4 A shunzi or Kezi . Shunzi means increasing continuously 3 A number card ( for example 234,567 etc. ), It means the same number 3 A number card ( for example 111,777)
for example :
1 1 1 2 2 2 6 6 6 7 7 7 9 9 It can make up 1,2,6,7 Of 4 A quarter and 9 The head of a bird , You can play cards
1 1 1 1 2 2 3 3 5 6 7 7 8 9 use 1 Make a bird's head , Group 123,123,567,789 The four shunzi , You can play cards
1 1 1 2 2 2 3 3 3 5 6 7 7 9 No matter what 1 2 3 7 Which is the head of a bird , Can't form and card conditions .
Now? , Small bag from 36 Draw out of cards 13 card , He wants to know about the rest of 23 Zhang paizhong , Take another card , What kinds of number cards can be taken to match the cards .
#include <iostream>
#include <vector>
using namespace std;
/* All in all 36 card , Each card is 1~9. Every number 4 card . You have... In your hand 14 card , If this 14 Cards meet the following conditions , That is, it's a sum of cards 14 There's... In the cards 2 A card with the same number , It's called a bird's head . Remove the above 2 card , be left over 12 Cards can make up 4 A shunzi or Kezi . Shunzi means increasing continuously 3 A number card ( for example 234, 567 etc. ), It means the same number 3 A number card ( for example 111, 777) */
vector<int> card(9);
// Check whether the remaining cards can form n A shunzi or Kezi
bool hasTrible(int n)
{
if (n == 0) return true;
for (int i = 0; i<card.size(); ++i)
{
// Because still from 1 Start inspection , So if you check the number of cards >=3, Then it must be engraved
if (card[i]>2)
{
card[i] -= 3;
if (hasTrible(n - 1))
{
// Check whether the remaining cards can form n-1 A shunzi or Kezi
card[i] += 3;
return true;
}
card[i] += 3;
}
// Otherwise, it can only be shunzi
else if (i<card.size() - 2 && card[i]>0 && card[i + 1]>0 && card[i + 2]>0)
{
card[i]--;
card[i + 1]--;
card[i + 2]--;
if (hasTrible(n - 1))
{
card[i]++;
card[i + 1]++;
card[i + 2]++;
return true;
}
card[i]++;
card[i + 1]++;
card[i + 2]++;
}
}
return false;
}
// Check 14 Whether a card can match a card
bool isWin()
{
for (int i = 0; i<9; ++i)
{
// In turn 1~9 Take it out as a bird's head , Check the rest 12 Whether a card is smooth or carved
if (card[i]<2)
continue;
card[i] -= 2;
if (hasTrible(4))
{
card[i] += 2;
return true;
}
card[i] += 2;
}
return false;
}
int main(){
vector<int> res;
int tmp;
for (int i = 0; i<13; ++i)
{
cin >> tmp;
card[tmp - 1]++;
}
for (int i = 0; i<9; ++i)
{
//1~9 Add... In turn , Check whether you can match the cards
if (card[i]>3)
continue;
card[i]++;
if (isWin()) // If you add this card, you can match it , Then add it to the output
res.push_back(i + 1);
card[i]--;
}
if (res.empty())
res.push_back(0);
for (int i = 0; i<res.size(); ++i)
cout << res[i] << ' ';
return 0;
}
边栏推荐
- I do live e-commerce in tiktok, UK
- 系统临时文件的写和读:createTempFile和tempFileContent[通俗易懂]
- Pytorch shows the summary like tensorflow
- 解决方案:idea project没有显示树状图
- TapNet: Multivariate Time Series Classification with Attentional Prototypical Network
- 评价自动化测试优劣的隐性指标
- Leetcode 02: sword finger offer 58 - I. flip the word order (simple); T123. Verify palindrome string; T9. Palindromes
- Principle, concept and construction process of MySQL database master-slave replication cluster
- JS字符串方法总结
- Leetcode 01: t1. sum of two numbers; T1108. IP address invalidation; T344. Reverse string
猜你喜欢
![[untitled] multimodal model clip](/img/f0/8ae72ae0845372b6fe2866fae83f52.png)
[untitled] multimodal model clip

Tlc549proteus simulation &sallen key filter &ad736vrms to DC conversion &proteus view 51 register value

Chapter 13 IO flow

解决方案:idea project没有显示树状图

npm踩坑

Shell script text three swordsmen sed

iptables防火墙
Do you really understand the underlying data structure skip list of Zset in redis?

I do live e-commerce in tiktok, UK

Solution of digital tube flash back after proteus8 professional version cracking
随机推荐
TapNet: Multivariate Time Series Classification with Attentional Prototypical Network
EfficientNet
The difference between microcomputer and single chip microcomputer
The chess robot "broke" the chess boy's finger...
Several rounds of SQL queries in a database
A possibility that ch340 module cannot be recognized / burned
Firewall firewall
Fundamentals of mathematics 01
53 亿 BI 市场 TOP 10:帆软、微软、永洪、SAP、百度、IBM、SAS、思迈特、Salesforce、浪潮通软
compute_ class_ weight() takes 1 positional argument but 3 were given
Solution of digital tube flash back after proteus8 professional version cracking
go入门篇 (3)
LNMP architecture setup (deploy discuz Forum)
[excerpt] [medical image] common DICOM thumbnail interpretation and viewer converter conversion tool
Makefile template
Finding the finite zero point of transfer function under different sampling periods
MySQL paging query instance_ MySQL paging query example explanation "suggestions collection"
About offline caching application cache / using manifest file caching
Detailed explanation of flask framework
Some commonly used shortcut keys for MathType