解题思路:
注意事项:
参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:606 |
打水问题 (C语言代码)浏览:1063 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:653 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:510 |
淘淘的名单 (C语言代码)浏览:1088 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:691 |
剪刀石头布 (C语言代码)浏览:748 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:586 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:519 |
1025题解浏览:732 |