177 条题解

  • -5
    @ 2023-2-25 18:32:01
    #include <bits/stdc++.h>
    using namespace std;
    struct Plus
    {
        int a,b;//定义一个结构体
    };
    stack<int> sta;//定义一个栈
    int main()
    {
        Plus c;//结构体变量
        cin >> c.a >> c.b;
        sta.push(c.a);//入栈
        sta.push(c.b);
        int s;
        s += sta.top();//输出栈顶元素
        sta.pop();//出栈
        s += sta.top();
        cout << s;//输出总和
        return 0;
    }
    
    • -5
      @ 2023-2-19 14:57:48

      呵呵,这是什么?� 废话不多说, 上正解:

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int a,b;
          cin >> a >> b;
          cout << a + b;
          return 0;
      }
      

      万能头文件

      #include <iostream>
      

      其实也不太好用(个人认为)

      • -5
        @ 2023-2-19 9:00:04

        include<bits/stdc++.h> using name space std: int main() { int a,b; cin >> a >> b; cout << a+b return 0; }

        • -5
          @ 2022-10-23 18:23:55

          #include <bits/stdc++.h>//这里我们写一下头文件(废话练习)


          using namespace std;


          int main()


          {


          int a,b;//定义变量a和b


          cin >> a >> b;//接受变量


          cout << a+b;//输出a,b的和


          return 0;


          }

          • -5
            @ 2022-10-9 21:08:02

            小号第一题。

            #include <iostream>
            using namespace std;
            int main()
            {
                int a,b;
                cin >> a >> b;
                cout << a+b;
                return 0;
            }
            
            • -5
              @ 2022-10-3 15:48:33
              #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int a,b;
                      cin >> a >> b;
                      cout << a+b;
                      return 0;
                  }
              
              • -5
                @ 2022-8-22 14:58:20
                #include<bits/stdc++.h>
                using namespace std;
                int main()
                {
                    int a,b;
                    cin>>a>>b;
                    cout<<a+b;
                    return 0;
                }
                

                先赞后看,养成习惯。👍 耶!

                • -5
                  @ 2022-8-22 14:26:58

                  #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b; return 0; }

                  • -5
                    @ 2022-8-21 21:18:18

                    这道题比较简单。核心代码就一句。 cout << a + b << endl;//输出a和b的和。

                    • -5
                      @ 2022-7-16 18:46:58
                      #include <iostream>
                      using namespace std;
                      int main()
                      {
                          int a, b;
                          cin >> a >> b;
                          cout << a + b;
                          return 0;
                      }
                      
                      • -5
                        @ 2022-5-23 21:26:27

                        #include <bits/stdc++.h> using namespace std; int main() { int a,b; cin >> a >> b; cout << a+b; return 0; }

                        • -6
                          @ 2023-1-16 18:39:01
                          啥 也 不 是
                          钛 简 单 了

                          [迷你世界-官方网站-想象无边界 创造无止境 (mini1.cn)](https://)

                        • -6
                          @ 2022-10-11 15:01:43

                          什么?看着像数据结构题。

                          再看看?LCT!

                          那就明显了。居然没有LCT的题解!不可思议!

                          struct node 
                          {
                              int data,rev,sum;
                              node *son[2],*pre;
                              bool judge();
                              bool isroot();
                              void pushdown();
                              void update();
                              void setson(node *child,int lr);
                          }lct[233];
                          int top,a,b;
                          node *getnew(int x)
                          {
                              node *now=lct+ ++top;
                              now->data=x;
                              now->pre=now->son[1]=now->son[0]=lct;
                              now->sum=0;
                              now->rev=0;
                              return now;
                          }
                          bool node::judge(){return pre->son[1]==this;}
                          bool node::isroot()
                          {
                              if(pre==lct)return true;
                              return !(pre->son[1]==this||pre->son[0]==this);
                          }
                          void node::pushdown()
                          {
                              if(this==lct||!rev)return;
                              swap(son[0],son[1]);
                              son[0]->rev^=1;
                              son[1]->rev^=1;
                              rev=0;
                          }
                          void node::update(){sum=son[1]->sum+son[0]->sum+data;}
                          void node::setson(node *child,int lr)
                          {
                              this->pushdown();
                              child->pre=this;
                              son[lr]=child;
                              this->update();
                          }
                          void rotate(node *now)
                          {
                              node *father=now->pre,*grandfa=father->pre;
                              if(!father->isroot()) grandfa->pushdown();
                              father->pushdown();now->pushdown();
                              int lr=now->judge();
                              father->setson(now->son[lr^1],lr);
                              if(father->isroot()) now->pre=grandfa;
                              else grandfa->setson(now,father->judge());
                              now->setson(father,lr^1);
                              father->update();now->update();
                              if(grandfa!=lct) grandfa->update();
                          }
                          void splay(node *now)
                          {
                              if(now->isroot())return;
                              for(;!now->isroot();rotate(now))
                              if(!now->pre->isroot())
                              now->judge()==now->pre->judge()?rotate(now->pre):rotate(now);
                          }
                          node *access(node *now)
                          {
                              node *last=lct;
                              for(;now!=lct;last=now,now=now->pre)
                              {
                                  splay(now);
                                  now->setson(last,1);
                              }
                              return last;
                          }
                          void changeroot(node *now)
                          {
                              access(now)->rev^=1;
                              splay(now);
                          }
                          void connect(node *x,node *y)
                          {
                              changeroot(x);
                              x->pre=y;
                              access(x);
                          }
                          void cut(node *x,node *y)
                          {
                              changeroot(x);
                              access(y);
                              splay(x);
                              x->pushdown();
                              x->son[1]=y->pre=lct;
                              x->update();
                          }
                          int query(node *x,node *y)
                          {
                              changeroot(x);
                              node *now=access(y);
                              return now->sum;
                          }
                          int main()
                          {
                              scanf("%d%d",&a,&b);
                              node *A=getnew(a);
                              node *B=getnew(b);
                              //连边 Link
                                  connect(A,B);
                              //断边 Cut
                                  cut(A,B);
                              //再连边orz Link again
                                  connect(A,B);
                              printf("%d\n",query(A,B)); 
                              return 0;
                          }
                          

                          就这样。

                          感觉少了点啥。

                          稍加思索,感觉线段树。

                          额,好像树状数组就行。

                          再来一只:

                          int lowbit(int a){
                              return a&(-a);
                          }
                          int main(){
                              int n=2,m=1;
                              int ans[m+1];
                              int a[n+1],c[n+1],s[n+1];
                              int o=0;
                              memset(c,0,sizeof(c));
                              s[0]=0;
                              for(int i=1;i<=n;i++){
                                  cin>>a[i];
                                  s[i]=s[i-1]+a[i];
                                  c[i]=s[i]-s[i-lowbit(i)];
                              }
                              for(int i=1;i<=m;i++)
                              {
                                  int q=2;
                                  int x=1,y=2;
                                  int s1=0,s2=0,p=x-1;
                                  while(p>0){
                                      s1+=c[p];
                                      p-=lowbit(p);
                                  }
                                  p=y;
                                  while(p>0){
                                      s2+=c[p];
                                      p-=lowbit(p);
                                  }  
                                  o++;
                                  ans[o]=s2-s1;
                              }
                              for(int i=1;i<=o;i++)
                                  cout<<ans[i]<<endl;//输出
                              return 0;
                          }
                          

                          (纯属娱乐)

                          • -6
                            @ 2022-8-16 14:14:00

                            #include <bits/stdc++.h> using namespace std; int main() { int a, b;//定义两个整数变量a,b cin>>a>>b;//输入a, b cout<<a + b;//输出a+b的和 return 0; }

                            • -6
                              @ 2022-7-28 18:04:33

                              #include <iostream>//必备工具 using namespace std; int main()//程序开始 { int a,b;//定义a和b cin>>a>>b;//赋值A和B cout<<a+b;//求和A与B,并输出 return 0;//程序结束 }

                              • -10
                                @ 2022-4-24 15:47:25

                                鼓励大家写题解,但注意题解格式。

                                给代码两端加上这个会舒服一些

                                ```cpp

                                你的代码

                                ```

                                </span>

                                这个点在键盘的左上角tab上面那个键,注意切换输入法

                                #include<iostream>
                                using namespace std;
                                int main()
                                {
                                    int n;
                                    cin>>n;//这是一个注释
                                    return 0;
                                } 
                                

                                请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                抄袭题解一经发现直接取消成绩。

                                • @ 2022-12-18 14:24:56

                                  这个是题解吗?

                                • @ 2023-2-19 13:43:23

                                  鼓励大家写题解,但注意题解格式。

                                  给代码两端加上这个会舒服一些

                                  ```cpp

                                  你的代码

                                  ```

                                  </span>这个点在键盘的左上角tab上面那个键,注意切换输入法

                                  #include<iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;//这是一个注释
                                      return 0;
                                  }
                                  

                                  请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                  抄袭题解一经发现直接取消成绩。

                                  鼓励大家写题解,但注意题解格式。

                                  给代码两端加上这个会舒服一些

                                  ```cpp

                                  你的代码

                                  ```

                                  </span>这个点在键盘的左上角tab上面那个键,注意切换输入法

                                  #include<iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;//这是一个注释
                                      return 0;
                                  }
                                  

                                  请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                  抄袭题解一经发现直接取消成绩。

                                  鼓励大家写题解,但注意题解格式。

                                  给代码两端加上这个会舒服一些

                                  ```cpp

                                  你的代码

                                  ```

                                  </span>这个点在键盘的左上角tab上面那个键,注意切换输入法

                                  #include<iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;//这是一个注释
                                      return 0;
                                  }
                                  

                                  请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                  抄袭题解一经发现直接取消成绩。

                                  鼓励大家写题解,但注意题解格式。

                                  给代码两端加上这个会舒服一些

                                  ```cpp

                                  你的代码

                                  ```

                                  </span>这个点在键盘的左上角tab上面那个键,注意切换输入法

                                  #include<iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;//这是一个注释
                                      return 0;
                                  }
                                  

                                  请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                  抄袭题解一经发现直接取消成绩。

                                  鼓励大家写题解,但注意题解格式。

                                  给代码两端加上这个会舒服一些

                                  ```cpp

                                  你的代码

                                  ```

                                  </span>这个点在键盘的左上角tab上面那个键,注意切换输入法

                                  #include<iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;//这是一个注释
                                      return 0;
                                  }
                                  

                                  请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                  抄袭题解一经发现直接取消成绩。

                              • -25
                                @ 2022-4-24 16:46:54

                                写题解请注意

                                鼓励大家写题解,但注意题解格式。

                                题解一定要有思路解析或代码注释,能否让别人理解你的思路

                                也是你的能力的检验,不要只放无意义的代码给大家复制,那就失去了做题的初心。

                                给代码两端加上这个会舒服一些

                                ```cpp

                                你的代码

                                ```

                                </span>

                                这个点在键盘的左上角tab上面那个键,注意切换输入法

                                #include<iostream>
                                using namespace std;
                                int main()
                                {
                                    int n;
                                    cin>>n;//这是一个注释
                                    return 0;
                                } 
                                

                                请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                                抄袭题解一经发现直接取消成绩。

                                题解被删除的可能

                                1. 代码不符合格式规范
                                2. 没有思路讲解或者没有注释,
                                3. 无意义的题解

                                大家携手共同维护一个良好的编程环境,如果一经发现,多次作乱。可能会被管理员拉黑,请注意,一旦拉黑即失去登陆资格。

                              【入门】熟悉一下Online Judge的环境

                              信息

                              ID
                              1
                              时间
                              1000ms
                              内存
                              16MiB
                              难度
                              6
                              标签
                              递交数
                              21681
                              已通过
                              7188
                              上传者