166 条题解

  • -3
    @ 2023-1-14 10:49:39

    A+B难度居然有1 c++风格

    #include<bits/stdc++.h>//好习惯
    int main(){//主函数
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);//可要可不要,是用来加速cin cout的,相关信息可以百度
    int a,b;
    std::cin>>>b;//因为cin是在std空间定义,我不写using就要在前面加std::
    std::cout<<a+b;//建议还是加using namespace std,不然不太方便
    }
    

    c风格

    #include<stdio.h>
    int main(){
    int a,b;
    scanf("%d%d",&a,&b);//%d是声明变量类型,&a是返回变量地址,直接变量名会出错
    printf("%d",a+b);//%d同上,a+b是计算
    //注意:c语言中没有using namespace std
    }
    

    其他不会

    • -3
      @ 2023-1-4 22:36:13
      #include<stdio.h>
      int main()
      {
          int a,b;
          scanf("%d%d",&a,&b);
          printf("%d",a+b);
          return 0;
      }
      
      • -3
        @ 2022-12-31 16:20:38
        #include<iostream> //头文件
        using namespace std; //命名空间
        int main(){ //主函数,程序从这里开始
            int a,b; //定义变量
            cin>>a>>b; //输入
            cout<<a+b<<endl; //输出他们的和
            return 0; //主函数需要返回0
        }
        
        
        • -3
          @ 2022-12-29 20:42:45
          #include<iostream>
          #define I int a,b;
          #define AK cin>>a>>b;
          #defing IOI cout<<a+b
          using namespace std;
          int main()
          {
              I AK IOI;
              return 0;
          }
          
          • -3
            @ 2022-12-7 21:28:42
            #include <iostream> //头文件
            
            using namespace std; //如果没有这一句,将无法正常使用cin, cout;
            
            int main () { //主函数
                int a, b; //定义,c++的变量必须先定义才能使用
                cin >> a >> b; //输入,相当于键入赋值
                cout << a + b << endl; //输出,endl指换行
                return 0; //结束程序
            }
            
            • -3
              @ 2022-11-7 19:23:40

              package luogu; import java.util.Scanner; public class a1 {

              public static void main(String[] args) {
              	// TODO Auto-generated method stub
              	int a=0;
              	int b=0;
              	Scanner sc=new Scanner(System.in);
              	for(int i=1;i<=2;i++) {
              	System.out.print("\t");
              	a=sc.nextInt();
              	b=sc.nextInt();
              	int c=a+b;
              	System.out.println(c);
              }
              }
              

              }

              • -3
                @ 2022-11-1 22:27:02

                Dijkstra+STL的优先队列优化。

                #include <iostream>
                #include <cstdio>
                #include <cstdlib>
                #include <cmath>
                #include <cctype>
                #include <climits>
                #include <algorithm>
                #include <map>
                #include <queue>
                #include <vector>
                #include <ctime>
                #include <string>
                #include <cstring>
                using namespace std;
                const int N=405;
                struct Edge {
                    int v,w;
                };
                vector<Edge> edge[N*N];
                int n;
                int dis[N*N];
                bool vis[N*N];
                struct cmp {
                    bool operator()(int a,int b) {
                        return dis[a]>dis[b];
                    }
                };
                int Dijkstra(int start,int end)
                {
                    priority_queue<int,vector<int>,cmp> dijQue;
                    memset(dis,-1,sizeof(dis));
                    memset(vis,0,sizeof(vis));
                    dijQue.push(start);
                    dis[start]=0;
                    while(!dijQue.empty()) {
                        int u=dijQue.top();
                        dijQue.pop();
                        vis[u]=0;
                        if(u==end)
                            break;
                        for(int i=0; i<edge[u].size(); i++) {
                            int v=edge[u][i].v;
                            if(dis[v]==-1 || dis[v]>dis[u]+edge[u][i].w) {
                                dis[v]=dis[u]+edge[u][i].w;
                                if(!vis[v]) {
                                    vis[v]=true;
                                    dijQue.push(v);
                                }
                            }
                        }
                    }
                    return dis[end];
                }
                int main()
                {
                    int a,b;
                    scanf("%d%d",&a,&b);
                    Edge Qpush;
                    
                    Qpush.v=1;
                    Qpush.w=a;
                    edge[0].push_back(Qpush);
                    
                    Qpush.v=2;
                    Qpush.w=b;
                    edge[1].push_back(Qpush);
                    
                    printf("%d",Dijkstra(0,2));
                    return 0;
                }
                
                
                
                • -3
                  @ 2022-10-6 14:31:17
                  
                  
                  #include<bits/stdc++.h>
                  
                  using namespace std;
                  
                  int ab(int a,int b)
                  {
                      return a+b;
                  }
                  
                  int main()
                  {
                      int a,b;
                      cin>>a>>b;
                      cout<<ab(a,b);
                  	return 0;
                  }
                  
                  //关于a+b我用函数解这件事
                  
                  • -3
                    @ 2022-8-18 17:11:48

                    甚至连变量都不用的快读。

                    代码如下:

                    #include<bits/stdc++.h>
                    using namespace std;
                    inline int read()
                    {
                        int x=0;
                        bool flag=1;
                        char c=getchar();
                        while(c<'0'||c>'9')
                        {
                            if(c=='-')
                                flag=0;
                            c=getchar();
                        }
                        while(c>='0'&&c<='9')
                        {
                            x=(x<<1)+(x<<3)+c-'0';
                            c=getchar();
                        }
                        return (flag?x:~(x-1));
                    }
                    int main()
                    {
                    	cout<<read()+read();
                    	return 0;
                    }
                    
                    • -3
                      @ 2022-8-5 22:44:17

                      水题一道,输入 aabb,然后输出他们的和即可。

                      #include<iostream>
                      using namespace std;
                      int main(){
                          int a, b;
                          cin >> a >> b;
                          cout << a + b << endl;
                          return 0;
                      }
                      
                      • -3
                        @ 2022-5-7 10:36:51

                        这题很简单,输入 a 和 b,然后输出他们的和即可。

                        #include <bits/stdc++.h>
                        using namespace std;
                        
                        int main()
                        {
                                int a,b;
                                cin >> a >> b;
                                cout << a + b;
                        	
                        	
                        
                        	return 0;
                        }
                        
                        • -3
                          @ 2022-3-22 12:54:54

                          这道题目就是输出 a+b 的和就OK了! AC Code:

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

                          注:我是新手,请多多请教!

                          • @ 2022-6-8 9:14:48

                            我不理解这种题解为什么会有人踩

                          • @ 2022-7-25 16:29:54

                            @因为没解释!

                        • -3
                          @ 2022-2-27 21:35:30
                          #include <cstdio>
                          using namespace std;
                          int n, m;
                          int main() {
                              scanf("%d %d", &n, &m);
                              printf("%d", n + m);
                              return 0;
                          }
                          
                          • -3
                            @ 2021-12-11 15:59:56

                            一份十分简洁的 py3 代码:

                            print(sum(map(int,input().split())))
                            

                            分析

                            map(int,input().split())
                            

                            这句话将第一行输入数据读入,然后将其按空格分裂成 list。map 函数将这个 list 中的每个元素变成 int。

                            print(sum(map(int,input().split())))
                            

                            接着,sum 函数求出了这个 list 内所有数的和,即 a+b。print 将其输出。

                            • -3
                              @ 2021-6-1 16:10:19

                              这是一道很简单的入门题。
                              可以直接写出代码:

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

                              感谢您的阅读。

                              • -3
                                @ 2021-4-19 6:47:31
                                
                                import java.util.Scanner;
                                public class Main {   
                                    private static Scanner s;
                                    public static void main(String[] args) {
                                        s = new Scanner(System.in); 
                                        int a = s.nextInt();
                                        int b = s.nextInt();
                                        System.out.println(a + b); 
                                    } 
                                }
                                
                                • -4
                                  @ 2024-1-28 13:57:08

                                  a

                                  • -4
                                    @ 2024-1-15 10:17:25

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

                                    • -4
                                      @ 2023-8-31 18:44:38

                                      这里估计大部分都是写了c++有一定基础的,那么我就用链表实现a+b问题吧

                                      #include <iostream>
                                      struct ListNode
                                      {
                                          int val;
                                          ListNode *next;
                                          ListNode(int x) : val(x), next(nullptr) {}
                                      };
                                      ListNode *addTwoNumbers(ListNode *l1, ListNode *l2)
                                      {
                                          ListNode *dummy = new ListNode(0);
                                          ListNode *current = dummy;
                                          int carry = 0;
                                          while (l1 || l2 || carry)
                                          {
                                              int sum = carry;
                                              if (l1)
                                              {
                                                  sum += l1->val;
                                                  l1 = l1->next;
                                              }
                                              if (l2)
                                              {
                                                  sum += l2->val;
                                                  l2 = l2->next;
                                              }
                                              carry = sum / 10;
                                              sum = sum % 10;
                                              current->next = new ListNode(sum);
                                              current = current->next;
                                          }
                                          return dummy->next;
                                      }
                                      ListNode *createLinkedList(int arr[], int n)
                                      {
                                          if (n == 0)
                                          {
                                              return nullptr;
                                          }
                                          ListNode *head = new ListNode(arr[0]);
                                          ListNode *current = head;
                                          for (int i = 1; i < n; i++)
                                          {
                                              current->next = new ListNode(arr[i]);
                                              current = current->next;
                                          }
                                          return head;
                                      }
                                      void printLinkedList(ListNode *head)
                                      {
                                          ListNode *current = head;
                                          while (current)
                                          {
                                              std::cout << current->val << " ";
                                              current = current->next;
                                          }
                                          std::cout << std::endl;
                                      }
                                      int main()
                                      {
                                          int arr1[1];
                                          int arr2[1];
                                          std::cin >> arr1[0];
                                          std::cin >> arr2[0];
                                          int n1 = sizeof(arr1) / sizeof(arr1[0]);
                                          int n2 = sizeof(arr2) / sizeof(arr2[0]);
                                          ListNode *l1 = createLinkedList(arr1, n1);
                                          ListNode *l2 = createLinkedList(arr2, n2);
                                          ListNode *sum = addTwoNumbers(l1, l2);
                                          printLinkedList(sum);
                                          return 0;
                                      }
                                      
                                      • -4
                                        @ 2023-8-2 16:18:31

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

                                        信息

                                        ID
                                        56
                                        时间
                                        1000ms
                                        内存
                                        1024MiB
                                        难度
                                        1
                                        标签
                                        递交数
                                        9734
                                        已通过
                                        4392
                                        上传者