蒟蒻17分的程序,大佬看看错哪?
查看原帖
蒟蒻17分的程序,大佬看看错哪?
310664
吴锦洋楼主2020/10/23 09:53
#include<bits/stdc++.h>
using namespace std;
int a,b;
int r[21]={0};
int s[21];
int t=0;
int q(int,int);
int ee(int);
int rrr=0;
int dd[21];
int main()
	{
	cin>>a>>b;
	for(int q=1;q<=a;q++)
		{cin>>s[q];
		}
		ee(1);
		cout<<rrr;
	return 0;
	}
int q(int ww)
	{
	int uu=2;
	while(ww%uu!=0&&uu*uu<=ww)uu++;
	if(uu*uu>ww)
   {return 1;
   }
   else
   {return 0;
   }
	 }
int ee(int tt)
	{for(int e=1;e<=a;e++)
		{
		 if(r[e]==0)
		 	{
			t=t+s[e];
		 	r[e]=1;
		 	dd[tt]=s[e];
			 if(tt==b)
		{if(q(t)==1)
			{rrr++;
			for(int w=1;w<b;w++)
				{cout<<dd[w]<<'+';
				}
				cout<<dd[b]<<endl;
			}
			t=0;
			return 0;
		}
		else
		{
		tt++;
		ee(tt);
	    }
		}
		}
	}
2020/10/23 09:53
加载中...