175 条题解

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

    • -4
      @ 2023-8-2 16:17:15

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

      • -4
        @ 2023-3-27 20:33:37
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        	ios::sync_with_stdio(false);
        	long long a,b;
        	cin>>a>>b;
        	cout<<a+b;
        	return 0;
        }
        
        • -4
          @ 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);
          }
          }
          

          }

          • -4
            @ 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;
            }
            
            
            
            • -4
              @ 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我用函数解这件事
              
              • -4
                @ 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;
                }
                
                • -4
                  @ 2022-7-25 16:25:22

                  这是一道基本的题,不会做这道题的都不好意思说自已学过OI (雾)

                  伪代码

                  导入头文件
                  主函数
                  {
                      整型 a, b
                      输入 a, b
                      输出 a, b
                  }
                  

                  真实代码

                  #include <bits/stdc++.h>// 万能头
                  
                  int main()// 主函数
                  {
                      int a, b;// 要加英文分号,int为整型
                      scanf("%d %d", &a, &b);// 输入,%d是整形输入,&一定要加!!
                      printf("%d", a + b);// 输出,C/C++支持直接用运算符
                      return 0;// 返回,代表着程序的结束(注:这条代码只是习惯的问题,觉得麻烦可以不写;返回值一般是0,当然也可以返回别的数)
                  }
                  
                  • -4
                    @ 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;
                    }
                    
                    • -4
                      @ 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); 
                          } 
                      }
                      
                      • -5
                        @ 2024-1-28 13:57:08

                        a

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

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

                          • -5
                            @ 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;
                            }
                            
                            • -5
                              @ 2023-3-12 19:21:44

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

                              • -5
                                @ 2021-11-21 11:17:25

                                更简短的文言代码:

                                施「require('fs').readFileSync」於「「/dev/stdin」」。名之曰「入」。
                                施「(x=>x.toString().trim().split(/[ \t\n]/))」於「入」。昔之「入」者。今其是矣。
                                夫「入」之一。取一以施「parseInt」。名之曰「甲」。
                                夫「入」之二。取一以施「parseInt」。加「甲」以其。書之。
                                
                                • -5
                                  @ 2021-4-19 22:19:18

                                  这是一道十分经典的题

                                  重要的地方就在于输入输出

                                  C++解法

                                  #include <iostream> //引入输入输出流头文件
                                  using namespace std;  
                                  int mian()         //主函数
                                  {
                                      int a, b;      //定义两个变量:a和b
                                      cin >> a >> b; //读入它们
                                      cout << a + b; //输出他们的和
                                      return 0;  
                                  }
                                  

                                  C解法

                                  #include <stdio.h>  //C语言的格式化输入输出头文件
                                  int main()          //主函数
                                  {
                                      int a, b;       //定义变量:a和b
                                      scanf("%d,%d", &a, &b);
                                      //这里运用了一个函数,他是scanf(格式化输入输出)
                                      //它的参数可以分成两大块,分别是格式和变量
                                      //格式可以使任意的,在格式字符串中要用%d来代替一个整数型变量
                                      //在后面的变量要和前面的代替符号(%d)一一对应,切记,变量前面需要加"&"(取址符)
                                      printf("%d", a + b);
                                      //这里又运用了一个和上面函数相对应的函数:printf(格式化输出)
                                      //同scanf,它前面是格式字符串,后面是对应的变量,但是,与scanf不同的是,后面的变量千万不要加"&"
                                      return 0;
                                  }
                                  

                                  Pascal解法

                                  var             {这是pascal特有的变量定义域}
                                   a, b:longint;  {定义两个长正型变量,这里注意不要用integer,会爆的哦}
                                  begin           {pascal中程序开始关键字(也可以用于循环或分支中代表开始)}
                                   write(a + b); {输出他们的和}
                                  end.            {pascal中程序结束的关键字(也可以用于循环或分支中代结束)}
                                  

                                  珍爱生命杜绝抄袭(我不会告诉你我加了防抄袭)

                                  • @ 2022-1-4 16:26:49

                                    反作弊误导新手。。。不推荐

                                • -6
                                  @ 2022-11-19 20:29:06

                                  倒过来输出

                                  • -6
                                    @ 2022-4-6 15:30:41

                                    c++新写法

                                    #include<bits/stdc++.h>

                                    using namespace std;

                                    int a,b;

                                    int main()

                                    {

                                    cin>>a>>b;

                                    cout<<a+b;

                                    return 0;

                                    }

                                    • -7
                                      @ 2021-11-9 16:40:50

                                      虽然这种简单题写个快读确实是大材小用, 但是有了快读,这个程序的主程序就可如python一般简洁

                                      因此就有了这篇题解,大家就当学快读的写法吧qwq

                                      #include <bits/stdc++.h>
                                      using namespace std;
                                      inline int read()
                                      {
                                          int X = 0; bool f = false; char ch = getchar();
                                          while (ch > '9' || ch < '0') {f |= ch == '-'; ch = getchar();}
                                          while (ch <= '9' && ch >= '0') {X = (X << 3) + (X << 1) + (ch ^ 48); ch = getchar();}
                                          return f ? -X : X;
                                      }
                                      inline void write(int X)
                                      {
                                          if (X == 0) {putchar('0'); return;}
                                          if (X < 0) {putchar('-'); X = -X;}
                                          short num[21], cnt = 0;
                                          while (X) {num[++cnt] = X % 10; X /= 10;}
                                          while (cnt) putchar(num[cnt--] ^ 48);
                                          return;
                                      }
                                      int main()
                                      {
                                          write(read() + read());
                                          return 0;
                                      }
                                      
                                      • -9
                                        @ 2022-8-21 14:37:57

                                        🚀️

                                        信息

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