当前位置:网站首页>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;
}边栏推荐
猜你喜欢

Day 3 experiment

新媒体运营策略(以小红书为例)帮助你快速掌握爆款创作方法

CMU AI PhD 第一年总结
![[training Day11] Calc [mathematics]](/img/a7/cbb33f0c241e1bad90a282bba990d1.png)
[training Day11] Calc [mathematics]

HCIE终到手,路才开始
![[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]](/img/46/1c7f6abc74e11c4c2e09655aade223.png)
[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]

Node.js operation database

Network security and level protection
![[文献阅读] - HRL -[HRL with Universal Policies for Multi-Step Robotic Manipulation]](/img/34/06d5ba3af4e6e775a335324c020161.png)
[文献阅读] - HRL -[HRL with Universal Policies for Multi-Step Robotic Manipulation]

【MySQL提权】UDF提权(附带大马)
随机推荐
The difference between "rewrite" and "overload"
[training day13] backpack [dynamic planning] [greed]
Mysql数据类型
Binder principle
recyclerview计算滑动距离之computeHorizontalScrollExtent-computeHorizontalScrollRange-computeHorizontalScrol
QT log file system
What is the difference between bio, NiO and AIO?
Why should we launch getaverse?
Day 3 experiment
What are the differences between FileInputStream and bufferedinputstream?
Hcie is finally in hand, and the road begins
Network Security Learning (16)
[PTA] 7-24 minimum fraction (15 points)
Deep recursion, deep search DFS, backtracking, paper cutting learning.
Can generic types be used in array
Structure principle of micro ball vibration switch with chip
Panzer_ Jack's personal blog founding day
Experiment 1, experiment 2 and Experiment 3 of assembly language and microcomputer principle: branch program design / loop program design / subroutine design
Kibana~后台启动Kibana之后无法找到进程号
IPFs of Internet Protocol