当前位置:网站首页>Ma Tiji Wanmin hall Chef
Ma Tiji Wanmin hall Chef
2022-07-25 22:55:00 【Elvin domain text】
Runtime error :
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
vector<vector<long long int>> res;
vector<long long int> arr2;
long long int target;
long long int start,last=0;
vector<long long int> temp;
long long int tim=0;
int OK(vector<long long int>a,long long int k,long long int i)// Determine whether there are duplicate elements
{
if(i>k)// Ensure that the array exists
for(int t=k;t<i;t++)// Loop search
{
if(a[t]==a[i])
return 0;
}
return 1;
}
void Perm(vector<long long int>a,long long int k,long long int m)// Full Permutation implementation function
{
if(k==m)// only 1 Elements
{
tim++;// frequency +1
// for(int i=0;i<=m;i++)
// {
// cout<<a[i];
// }
// cout<<"\n";
}
else // There are more elements to arrange
{
for(int i=k;i<=m;i++)// There are a few elements that cycle several times ( Because it starts , Then arrange the following numbers completely )
{
if(OK(a,k,i))// When there is no repeating element , Before full arrangement
{
swap(a[k],a[i]);// swapping
Perm(a,k+1,m);
swap(a[k],a[i]);
}
}
}
}
int helper(vector<long long int> arr, long long int target, vector<long long int> arr2, long long int index){
if(target==0)
{
res.insert(res.end(),arr2);
}
for(int i=index; i<arr.size();i++){
if(arr[i] <= target){
arr2.insert(arr2.end(),arr[i]);
helper(arr, target-arr[i], arr2, i);
arr2.pop_back();
}
}
}
vector<vector<long long int>> combinationSum(vector<long long int> arr, long long int target){
helper(arr, target, arr2, 0);
return res;
}
int main()
{
vector<long long int> arr; // The original array
long long int n,m,k,x;
cin >> x >> n >> m >> k;
target = x;
arr.insert(arr.end(),n);
arr.insert(arr.end(),m);
arr.insert(arr.end(),k);
combinationSum(arr,target);
for(int i=0;i<res.size();i++){
for(int j=0;j<res[i].size();j++){
start = 0;
temp.insert(temp.end(), res[i][j]);
}
last = res[i].size()-1;
Perm(temp, start, last);
temp.clear();
}
if(tim){
cout << tim%mod;
}
else{
cout << "impossible";
}
// cout << " The number of components is :" << tim ;
return 0;
}边栏推荐
- Interview question 17.11. word distance ●●
- QT log file system
- Interpretation of English terms
- QT的Tree View Model示例
- DOM event object
- 互联网协议之 IPFS
- Ssh server CBC encryption mode vulnerability (cve-2008-5161)
- Structure principle of micro ball vibration switch with chip
- Document flow definition, box model related knowledge
- Summary of traversal methods of six sets list, set, map, queue, deque and stack
猜你喜欢
![[training day15] boring [tree DP]](/img/78/dc80076bb9fc4cf008c51b00ece431.png)
[training day15] boring [tree DP]

Review of static routing

Stack and stack class

【论文笔记】A Meta-Reinforcement Learning Algorithm for Causal Discovery
![[training day15] paint road [minimum spanning tree]](/img/12/2d4ad1e2b8133b6c92875faa4b4182.png)
[training day15] paint road [minimum spanning tree]
![[training Day11] Nescafe [greed]](/img/4f/c9c7ae8a7b09ee58dd0fdbc55baf72.png)
[training Day11] Nescafe [greed]

Simple setting of drop-down triangle

Anaconda~Upload did not complete.

Binder principle
![[training Day12] x equation [high precision] [mathematics]](/img/4f/51d902e925f9ec60da46d161ed4d17.png)
[training Day12] x equation [high precision] [mathematics]
随机推荐
【论文笔记】基于在线预测和规划的机器人动态跟踪抓取方法
Hcie is finally in hand, and the road begins
Review of static routing
Oracle query statement summary
Today, let's talk about the if branch statement of the selection structure
单元测试,写起来到底有多痛?
The difference between "= =" and equals
[training day13] Internet [concurrent search]
[training day15] paint road [minimum spanning tree]
Experience of machine learning with Google Lab
汇编语言与微机原理实验一、实验二、实验三:分支程序设计/循环程序设计/子程序设计
CUDA environment construction
Network Security Learning (XII) OSI and TCP
Analysis of Excel file
Box model (2)
QT Chinese programming encounters c2001 error, prompting "there is a newline character in the constant"
Anaconda~Upload did not complete.
2020-09-17
Vodak software: Smart City solution
Floating effect and characteristics