题解

1325 条题解

  • 16
    @ 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。

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

  • 6
    @ 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
    @ 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
    @ 2024-10-24 14:24:10
    #include<iostream>
    using namespace std;
    int main() {
        int a,b;
        cin >> a >> b;
        cout << a + b;
        return 0;
    }
    
  • 1
    @ 2024-08-27 19:43:03

    C++基本格式

    #include <iostream>
    using namespace std;
    int main(void) {
        return 0;
    }
    

    在第3行后面添加代码。

    int a, b;//定义两个变量a和b
    cin >> a >> b;//输入a和b
    cout << a + b;//计算a + b并把结果输出
    

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

  • 1
    @ 2024-03-21 20:45:30
    main(a,b){scanf("%d%d",&a,&b);printf("%d",a+b);}
    
    
  • 1
    @ 2024-03-21 20:42:40
    
    #include<bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    template<class T> void read(T &x) {
        x = 0; T f = 1; char c = getchar();
        for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
        for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 48; x *= f;
    }
    template<class T> void write(T x) {
        if (x > 9) write(x / 10); putchar(x % 10 + 48);
    }
    template<class T> void print(T x, char ed = '\n') {
        if (x < 0) putchar('-'), x = -x; write(x), putchar(ed);
    }//抄来的快读快写
    int main(){
        ll a,b;
        read(a);
        read(b);
        print(a+b);
        return 0;
    }
    
    
  • 1
    @ 2023-06-15 22:11:05

    超级大模拟:
    #include <iostream>
    #include <cmath>
    using namespace std;
    int fu=1,f=1,a,b,c=0;
    int main()
    {
    cin>>a>>b;
    if(a<0&&b>0)fu=2;
    if(a>0&&b<0)fu=3;
    if(a<0&&b<0)f=-1;
    if(a==0){cout<<b;return 0;}
    if(b==0){cout<<a;return 0;}
    a=abs(a);
    b=abs(b);
    if(a>b&&fu==3)f=1;
    if(b>a&&fu==3)f=-1;
    if(b>a&&fu==2)f=1;
    if(b<a&&fu==2)f=-1;
    if(fu==1)c=a+b;
    if(fu>1)c=max(a,b)-min(a,b);
    c*=f;
    cout<<c;
    return 0;
    }

  • 1
    @ 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;
    }
    
    
    
  • 1
    @ 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;
    }
    
  • 1
    @ 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;
    }

  • 1
    @ 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;
    }
    
    
  • 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
    @ 2025-04-10 20:26:57
    #include<bits/stdc++.h>
    using namespace std;
    struct sb{
        int a,b;
    };
    int main(){
        sb n;
        cin>>n.a>>n.b;
        cout<<n.a+n.b<<'\n';
    }
    
  • 0
    @ 2025-01-23 21:02:19

    什么是一行?它(Python 3)说……
    python
    print(sum(map(int, input().split()))

  • 0
    @ 2024-11-09 16:36:24

    水题中的水题中的水题

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        long long a,b;
        cin>>a>>b;
        cout<<a+b;
    
        return 0;
    }
    
  • 0
    @ 2024-08-30 19:03:01

    #include<bits/stdc++.h>
    using namespace std;
    long long a[1000],b[1000],c[1000];
    int main(){
    string s,s1;
    cin>>s>>s1;
    for(int i=0;i<s.size();i++){
    a[i]=s[s.size()-1-i]-'0';
    }
    for(int j=0;j<s1.size();j++){
    b[j]=s1[s1.size()-1-j]-'0';
    }
    int l;
    if(s.size()>s1.size()){
    l=s.size();
    }else{
    l=s1.size();
    }
    for(int i=0;i<l;i++){
    c[i]=a[i]+b[i];
    }
    for(int i=0;i<l;i++){
    if(c[i]>=10){
    c[i]=c[i]-10;
    c[i+1]++;
    }
    }
    if(c[l]!=0){
    l++;
    }
    for(int i=l-1;i>=0;i--){
    cout<<c[i];
    }
    return 0;
    }

  • 0
    @ 2024-08-24 10:07:41

    非常简单的新手入门题
    ```cpp
    #include <iostream>
    //头文件
    using namespace std;
    //命名空间
    int main()
    {
    int a,b;//定义
    cin>>a>>b;//输入
    cout<<a+b<<endl;//输出
    }

  • 0
    @ 2024-08-13 16:28:00

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    int x,y;
    cin>>x>>y;
    if(0<=x,y<=32767){
    cout<<x+y;
    }else{
    cout<<"NO";
    }
    return 0;
    }
    此题非常的简单
    直接一个if()就可以过

信息

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