进阶20给出一个整数 nn10^30) 和 k 个变换规则规则一位数可变换成另一个一位数变换得到的数不能为零。仅要求输出经过任意次的变换产生出不同整数的个数。例如n234。有规则k22 53 6上面的整数 234 经过变换后可能产生出的整数为包括原数:234534264564共 4 种不同的产生数经过测试每一位数字的变化能经过多次变化规则。DFS列出所有可能数字过于复杂且数据规模超过int的数量级。列出数字形式是考虑到形成不同的数字才能计数。实际上每一位取到不同的数字得到的结果都是不同的不需要形成数字后进行比较是否重复。数据规模总次数超过int上限用数组的大数乘和string接收字符串。#include bits/stdc.h using namespace std; vectorint orgin; vectorint target; vectorint ans; vectorint FinAns; void GetNum(vectorint UsedNum, int cur) { // 如果当前数字已经在 UsedNum 里说明已经处理过避免重复 if (find(UsedNum.begin(), UsedNum.end(), cur) ! UsedNum.end()) { return; } UsedNum.push_back(cur); // 尝试所有规则看 cur 能变成什么 for (int i 0; i orgin.size(); i) { if (orgin[i] cur) { //对新变化的数检查是否存在新转化规则 GetNum(UsedNum, target[i]); } } } void DFS(vectorint numbers,int index,vectorint UsedNum){ if(indexnumbers.size()){ return; } //得到该位能取到的全部数字 GetNum(UsedNum,numbers[index]); ans.push_back(UsedNum.size()); vectorint newUsedNum; DFS(numbers,index1,newUsedNum); return; } void DaShuCheng(int index,int jin){ int num ans[index]; if(index0){ FinAns.push_back(num); } else{ for(int i0;iFinAns.size();i){ FinAns[i]*num; FinAns[i]jin; jin FinAns[i]/10; FinAns[i]%10; } if(jin){ FinAns.push_back(jin); jin0; } } } int main(){ string num; int len; cinnumlen; vectorint numbers; for(int i0;inum.size();i){ numbers.push_back(num[i] - 0); } for(int i0;ilen;i){ int map1,map2; cinmap1map2; orgin.push_back(map1); target.push_back(map2); } vectorint UsedNum;//记录index对应数字的变化形式 DFS(numbers,0,UsedNum); int jin0; for(int i0;ians.size();i){ DaShuCheng(i,jin); } reverse(FinAns.begin(),FinAns.end()); for(int i0;iFinAns.size();i){ coutFinAns[i]; } system(pause); }进阶21将念头从1到n编号念头i来源于念头from[i]保证from[i]ifrom[i]0表示该念头没有来源念头只是脑袋一抽灵光一现。输出共一行一个正整数L表示最长的念头因果链中的念头数量样例输入801032424样例输出3样例说明最长的因果链有1-2-5 (from[5]2,from[2]1,from[1]0)1-2-7 (from[7]2,from[2]1,from[1]0)3-4-6 (from[6]4,from[4]3,from[3]0)3-4-8 (from[8]4,from[4]3,from[3]0)错误1越界异常产生死循环了错误在于来源是编号1~n而对应下标为1-1~n-1。将TraceBack(LianChang,newindex,from);改为TraceBack(LianChang,newindex-1,from);#include bits/stdc.h using namespace std; void TraceBack(int LianChang,int index,vectorintfrom){ LianChang; if(from[index]0){ return ; } else{ int newindex from[index]; TraceBack(LianChang,newindex-1,from); } } int main(){ int len;cinlen; vectorint from(len); for(int i0;ilen;i){ cinfrom[i]; } int LianChang0; int ans0; for(int i0;ilen;i){ LianChang0; TraceBack(LianChang,i,from); ans max(ans,LianChang); } coutansendl; system(pause); }In recent years, pre-trained models have played an important role in artificial intelligence research. Researchers typically first train a general model using large-scale datasets and then fine-tune it on specific tasks. In this way, the model can utilize the knowledge learned during the pre-training stage to improve the performance of downstream tasks. For example, in the field of natural language processing, many language models are pre-trained on massive text corpora and achieve excellent results in tasks such as text classification, machine translation, and question answering. The pre-training and fine-tuning framework not only reduces training costs but also improves the generalization ability of models. Therefore, this approach has become an important paradigm in modern artificial intelligence research.近年来预训练模型在人工智能研究中扮演了重要的角色。研究员普遍地使用大规模数据集来先训练一个普遍的模型再在特定任务中调优。在这种方式里模型能在预训练阶段利用学习到的知识来改善下游任务中的表现。比如在自然语言处理领域中许多语言模型再大量的文本语料库中预训练并在一些任务中取得了极好的结果比如文本分类、机器翻译和回答问题。预训练和微调架构不仅减少了训练成本还提高了模型的泛化能力。从而这一方法在现代化的人工智能研究中成为了一个重要范例。downstream tasks 下游任务、 fine-tuning 微调