MySoul


私信TA

用户名:18813155923

访问量:3115

签 名:

跟C语言网说拜拜了,转战洛谷去咯!

等  级
排  名 93
经  验 8490
参赛次数 0
文章发表 8
年  龄 18
在职情况 学生
学  校 北方工业大学
专  业 计算机科学与技术

  自我简介:

解题思路:

注意事项:

参考代码:

#include <iostream>
#include<map>
#include<vector>
using namespace std;
map<int,vector<int>> mp;
int sum=0;
int pow(int t)
{
	int p=1;
	for(int i=0;i<t;i++)p*=3;
	return p;
}
void dfs(int step,int sum,vector<int> t)
{
	if(step==10)
	{
		mp[sum]=t;return;
	}
	t.push_back(9);
	dfs(step+1,sum-pow(step),t);
	t.erase(t.end()-1,t.end());
	t.push_back(10);
	dfs(step+1,sum,t);
	t.erase(t.end()-1,t.end());
	t.push_back(11);
	dfs(step+1,sum+pow(step),t);
	t.erase(t.end()-1,t.end());
}
int main()
{
	int w;
	vector<int> t;
	dfs(0,0,t);
	while(cin>>w)
	{
		w-=295240;
		for(int i=0;i<10;i++)
		{
			cout<<mp[w][i]<<" ";
		}
		cout<<endl;
	}
}


 

0.0分

3 人评分

  评论区