• 笔试强训第十九天 (最长公共子串+汽水瓶)


    选择

     C

     

     C

     

     

     应该为

    p->llink->rlink=p->rlink;

    p->rlink->llink=p->llink;

     

     C

     

    循环队列的抽象图如下  数组里面可以放M个数 但队列只能放M-1个,队列满时end2指向的就是那个空位置,空位置+1就是end1的位置,所以(end2+1)%M==end1。循环队列之所以成立,就是因为end2大于数组下标后,可以回到数组的起始位置。也可以通过(end1-1+M)%M==end2来判断

     

    后序遍历的最后一个元素是根节点,在中序遍历中找到这个点 这个点以左是构成左子树,这个点以右构成右子树。

    a的左树由b构成,a的右树由defcg构成。

    在后序遍历中除去a和已使用的b,可以得知a的右树的根节点是d,来到中序遍历,得知d的左树没有元素,d的右树由efcg构成。

    在后序遍历中除去d,得知d的右树的根节点是c,在中序遍历中找到c,发现c的左树由ef构成,c的右树由g构成。

    在后序遍历中除去c,得知c的左树的根节点是e,e的右子树由f构成

     

    二叉树的性质

    n0=n2+1; n0=199+1=200

     

    D

     %13==1即可

    14 1 27 79

     D

     编程

    汽水瓶

    汽水瓶_牛客题霸_牛客网

    1. #include
    2. using namespace std;
    3. int get_count(int n)
    4. {
    5. int res=0;
    6. while(n>1)
    7. {
    8. int use=n/3;
    9. int left=n%3;
    10. res+=use;
    11. n=left+use;
    12. if(n==2)
    13. {
    14. res++;
    15. break;
    16. }
    17. }
    18. return res;
    19. }
    20. int main()
    21. {
    22. int n;
    23. while(cin>>n)
    24. {
    25. if(n==0) break;
    26. else
    27. {
    28. cout<<get_count(n)<
    29. }
    30. }
    31. return 0;
    32. }

    最长公共子串

    最长公共子串__牛客网

    1. #include
    2. #include
    3. #include
    4. using namespace std;
    5. string getComSubstr(string& s1,string& s2)
    6. {
    7. //让短的字符串是s1
    8. if(s1.size()>s2.size()) swap(s1,s2);
    9. int n=s1.size(),m=s2.size();
    10. vectorint>>dp(n,vector<int>(m,0));//n行m列
    11. int start=0,maxsize=0;
    12. for(int i=0;i
    13. {
    14. for(int j=0;j
    15. {
    16. if(s1[i]==s2[j])
    17. {
    18. if(i>=1 && j>=1) dp[i][j]=dp[i-1][j-1]+1;
    19. else dp[i][j]=1;
    20. }
    21. if(dp[i][j]>maxsize)
    22. {
    23. maxsize=dp[i][j];
    24. start=i-maxsize+1;//注意这个+1
    25. }
    26. }
    27. }
    28. return s1.substr(start,maxsize);
    29. }
    30. int main()
    31. {
    32. string str1, str2;
    33. while(cin >> str1 >> str2)
    34. {
    35. string substr = getComSubstr(str1, str2);
    36. if(substr.empty()) cout<<-1<
    37. else cout<
    38. }
    39. return 0;
    40. }

  • 相关阅读:
    精简scrapy日志冗余占较大内存
    快速学习微服务保护框架--Sentinel
    解析gin框架部分收获
    【原型链污染】Python与Js
    nginx使用keepalived做高可用
    源来Intel——开放原子全球峰会
    C++模拟与高精度——帮贡排序
    C++ STL教程
    Vim常用命令汇总
    选调生、高校人才引进(暂存笔记)
  • 原文地址:https://blog.csdn.net/qq_68741368/article/details/127740997