题解

1330 条题解

  • 15
    @ 2018-05-01 16:13:03

    告诉你们什么叫做暴力的题解。

    #include<bits/stdc++.h>
    #define gou int main()
    #define li {
    #define guo int a,b;
    #define jia cin>>a>>b;
    #define sheng cout<<a+b;
    #define si return 0;
    #define yi }
    using namespace std;
    gou
    li
    guo
    jia
    sheng
    si
    yi
    
    • @ 2018-05-01 22:51:50

      #include<bits/stdc++.h>
      #define qi int main()
      #define yin
      {
      #define huo int a,b;
      #define fu cin>>a>>b;
      #define bi cout<<a+b;
      #define qu return 0;
      #define zhi
      }
      using namespace std;
      qi
      yin
      huo
      fu
      bi
      qu
      zhi

    • @ 2019-07-11 18:13:13

      学习了

    • @ 2020-05-18 20:07:53

      zzmg,jbl(

    • @ 2021-08-29 18:54:26

      你是秀儿

    • @ 2022-02-27 13:37:34

      @Louisssss: 太秀了

  • 11
    @ 2021-08-30 11:48:08

    本题直接用 int 就能过。
    完整代码:

    #include<iostream> //引入 iostream 头文件
    using namespace std; //使用 std 命名空间
    int main(){ //主函数,程序从这里开始
        int a,b; //定义两个变量,一个叫 a ,一个叫 b
        cin>>a>>b; //输入
        cout<<a+b; //输出他们的和
        return 0; //主函数应返回 0
    }
    

    讲解:
    - iostream 头文件也叫输入输出流,是 C++ 特有的头文件,用来输入和输出。
    - std 命名空间是 C++ 的标准命名空间,输入输出就定义在这里面。
    - int main() 函数是程序的开始,一个程序必须有他。
    - int a,b 是定义了两个 int 型变量,\(a\) 和 \(b\)。
    - cin>>a>>b 是在输入 \(a\) 和 \(b\)。
    - cout<<a+b 是在输出 \(a+b\)。
    - return 0int main() 函数的返回值,这个返回值必须是 \(0\) ,不然会 RE。

    管理员大大求通过
    看在我写得这么认真的情况下,就给我点个赞吧

  • 4
    @ 2023-10-07 23:22:21
    /********************************************************
    备注:
    ********************************************************/
    #include <iostream>
    #include <iomanip>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <cstdio>
    using namespace std;
    #define LL long long
    #define MAXM 3010
    #define MAXN 3010
    const int N =1e5+10;
    const int INF =0x3f3f3f3f;
    int main ()
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
       return 0;
    }
    
  • 1
    @ 2025-12-06 12:44:23

    这题是简单的\(A+B\)问题,常常作为系统测试题目使用,C++主流写法有两类:

    1. ### 主程序写法
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d",a+b);
    }
    

    注:这里的第二种写法更偏向于C风格,但在需要快速读入你又不会快读的时候,这种写法能体现出略微的优势。

    1. ### asm写法
    #include<iostream>
    using namespace std;
    int main(){
        int a,b,sum;
        cin>>a>>b;
        asm volatile(
            "movl %1,%%eax\n\t"
            "addl %2,%%eax\n\t"
            "movl %%eax,%0"
            :"=r"(sum)
            :"r"(a),"r"(b)
            :"eax"
        );
        cout<<sum;
    }
    
  • 1
    @ 2024-10-28 09:36:20

    想要更简单做法请移步至其他题解。

    本题有一种好想但码量较大的做法,可以直接将问题转化为网络流模型,跑一边最大流就可以了。为防止 TLE 特地学习了一遍预流推进。

    #include<bits/stdc++.h>
    using namespace std;
    const int N=2e4+5,M=2e5+5,inf=0x3f3f3f3f;
    int n,s,t,tot;
    int v[M<<1],w[M<<1],first[N],nxt[M<<1];
    int h[N],e[N],gap[N<<1],inq[N];
    struct cmp
    {
        inline bool operator()(int a,int b) const
        {
            return h[a]<h[b];
        }
    };
    queue<int> Q;
    priority_queue<int,vector<int>,cmp> pQ;
    inline void add_edge(int from,int to,int flow)
    {
        tot+=2;
        v[tot+1]=from;v[tot]=to;w[tot]=flow;w[tot+1]=0;
        nxt[tot]=first[from];first[from]=tot;
        nxt[tot+1]=first[to];first[to]=tot+1;
        return;
    }
    inline bool bfs()
    {
        int now;
        int go;
        memset(h+1,0x3f,sizeof(int)*n);
        h[t]=0;Q.push(t);
        while(!Q.empty())
        {
            now=Q.front();Q.pop();
            for(go=first[now];go;go=nxt[go])
                if(w[go^1]&&h[v[go]]>h[now]+1)
                    h[v[go]]=h[now]+1,Q.push(v[go]);
        }
        return h[s]!=inf;
    }
    inline void push(int now)
    {
        int d;
        int go;
        for(go=first[now];go;go=nxt[go])
            if(w[go]&&h[v[go]]+1==h[now])
            {
                d=min(e[now],w[go]);
                w[go]-=d;w[go^1]+=d;e[now]-=d;e[v[go]]+=d;
                if(v[go]!=s&&v[go]!=t&&!inq[v[go]])
                    pQ.push(v[go]),inq[v[go]]=1;
                if(!e[now])
                    break;
            }
        return;
    }
    inline void relabel(int now)
    {
        int go;
        h[now]=inf;
        for(go=first[now];go;go=nxt[go])
            if(w[go]&&h[v[go]]+1<h[now])
                h[now]=h[v[go]]+1;
        return;
    }
    inline int hlpp()
    {
        int now,d;
        register int i,go;
        if(!bfs())
            return 0;
        h[s]=n;
        memset(gap,0,sizeof(int)*(n<<1));
        for(i=1;i<=n;i++)
            if(h[i]<inf)
                ++gap[h[i]];
        for(go=first[s];go;go=nxt[go])
            if(d=w[go])
            {
                w[go]-=d;w[go^1]+=d;e[s]-=d;e[v[go]]+=d;
                if(v[go]!=s&&v[go]!=t&&!inq[v[go]])
                    pQ.push(v[go]),inq[v[go]]=1;
            }
        while(!pQ.empty())
        {
            inq[now=pQ.top()]=0;pQ.pop();push(now);
            if(e[now])
            {
                if(!--gap[h[now]])
                    for(i=1;i<=n;i++)
                        if(i!=s&&i!=t&&h[i]>h[now]&&h[i]<n+1)
                            h[i]=n+1;
                relabel(now);++gap[h[now]];
                pQ.push(now);inq[now]=1;
            }
        }
        return e[t];
    }
    int m;
    signed main()
    {
        int x,y;
        cin>>x>>y;
        n=4,m=4,s=1,t=4;
        add_edge(1,2,x);
        add_edge(1,3,y);
        add_edge(2,4,10000000);
        add_edge(3,4,10000000);
        printf("%d\n",hlpp());
        return 0;
    }
    
  • 1
    @ 2022-05-08 18:14:23

    基础语法

    //头文件
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <cstdio>
    #include <cmath>
    //命名空间
    using namespace std;
    
    //主函数
    int main()
    {
        int x, y; //定义x,y
        //int类型,用"%d"输出
        scanf("%d%d", &x, &y); //输入x,y
        printf("%d", x + y); //输出x + y
        return 0;
    }
    
  • 0
    @ 2023-05-26 16:53:32

    居然没看到2行代码,那我就来写一个

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

    原代码

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
          int a,b;
          cin>>a>>b;
          a += b;
          cout<<a<<endl;
          return 0;
    }
    
    
    
  • 0
    @ 2023-05-26 16:50:15

    大水题,废话不多说,上代码

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b;
        cin>>a>>b;
          a += b;
        cout<<a<<endl;
        return 0;
    }
    
  • 0
    @ 2023-05-15 19:08:30

    这题比较难
    #include<iostream>
    using namespace std;
    int main()
    {
    int m,n;
    cin>>m>>n;
    cout<<m*m*m*m*m/m/m/m/m+n*n*n*n*n/n/n/n/n;
    }

  • 0
    @ 2022-10-06 23:31:29

    这道题就是逊啦!!!

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    
    
  • 0
    @ 2022-06-24 22:11:47
    #include<bits/stdc++.h>
    using namespace std;
    signed main(){
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    
  • 0
    @ 2022-06-14 10:07:01

    来一篇好玩的题解。

    #include <bits/stdc++.h>
    
    #define _ using
    #define __ namespace
    #define ___ std;
    #define ____ int
    #define _____ main() {
    #define ______ int a, b;
    #define _______ cin >> a >> b;
    #define ________ cout << a + b << '\n';
    #define _________ }
    _ __ ___
    ____ _____
        ______ _______ ________ _________
    
    
  • 0
    @ 2022-05-06 19:54:07

    本小弟第一次发题解
    #include <iostream>
    using namespace std;
    int main(){
    long long a,b;//注意,不开long long见祖宗
    cin>>a>>b;
    cout<<a+b;//很水
    }

  • 0
    @ 2022-04-29 20:59:18

    暴力解题之进阶版

    #include <iterator>
    #include <functional>
    #include<vector>
    #include<deque>
    #include<list>
    #include<queue>
    #include<stack>
    #include<set>
    #include<map>
    #include<algorithm>
    #include<numeric>
    #include<memory>
    #include<utility>
    #define gou int main()
    #define li {
    #define guo int a,b;
    #define jia cin>>a>>b;
    #define sheng cout<<a+b;
    #define si return 0;
    #define yi }
    using namespace std;
    gou
    li
    guo
    jia
    sheng
    si
    yi

  • 0
    @ 2022-04-09 15:30:33
    
    #include<bits/stdc++.h>
    using namespace std;
    int n,m;
    int main(){
    cin>>n>>m;
    cout<<n+m;
        return 0;
    }
    
    
  • 0
    @ 2022-03-18 11:18:59

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    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;
    }

  • 0
    @ 2022-03-12 16:43:12
    #include<iostream>//头文件
    using namespace std;//命名空间
    int main()//主函数
    {
        int a,b;//定义变量a b
            cin>>a>>b;//输入变量a b
            cout<<a+b<<endl;//输出a与b的和
        return 0;//返回值
    }
    
  • 0
    @ 2022-03-12 16:40:27

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

  • 0
    @ 2022-03-12 16:40:22

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

  • 0
    @ 2022-02-27 13:49:38

    最基础的A+B解法(给蒟蒻看的)

    
    #include <iostream>//头文件很重要
    using namespace std;
    int main()//主函数
    {
       int a,b,c;//定义三个变量a,b,c
       cin >> a >> b;//输入a,b值
       c = a+b;//求和并存入c中
       cout << c;//输出c
       return 0;
    }
    
    

    点个赞再走呗,跪谢!ヾ(≧▽≦*)o

信息

ID
1000
难度
9
分类
(无)
标签
(无)
递交数
75153
已通过
28744
通过率
38%
被复制
265