14 条题解

  • 5
    @ 2021-4-19 13:50:21

    BZOJ 官方题解:

    Q: Where are the input and the output? A: Your program shall always read input from stdin (Standard Input) and write output to stdout (Standard Output). For example, you can use scanf in C or cin in C++ to read from stdin, and use printf in C or cout in C++ to write to stdout. You shall not output any extra data to standard output other than that required by the problem, otherwise you will get a Wrong Answer. User programs are not allowed to open and read from/write to files. You will get a Runtime Error or a Wrong Answer if you try to do so. Here is a sample solution for problem 1000 using C++/G++:

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

    It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error. Here is a sample solution for problem 1000 using C/GCC:

    #include <stdio.h>
    int main()
    {
        int a,b;
        scanf("%d %d",&a, &b);
        printf("%d\n",a+b);
        return 0;
    }
    

    Here is a sample solution for problem 1000 using PASCAL:

    program p1000(Input,Output);
    var
      a,b:Integer;
    begin
      Readln(a,b);
      Writeln(a+b);
    end.
    

    Here is a sample solution for problem 1000 using JAVA: Now java compiler is jdk 1.5, next is program for 1000

    import java.io.*;
    import java.util.*;
    public class Main
    {
        public static void main(String args[]) throws Exception
        {
            Scanner cin=new Scanner(System.in);
            int a=cin.nextInt(),b=cin.nextInt();
            System.out.println(a+b);
        }
    }
    

    Old program for jdk 1.4

    import java.io.*;
    import java.util.*;
    public class Main
    {
        public static void main (String args[]) throws Exception
        {
            BufferedReader stdin =
            new BufferedReader(
            new InputStreamReader(System.in));
            String line = stdin.readLine();
            StringTokenizer st = new StringTokenizer(line);
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            System.out.println(a+b);
        }
    }
    
    
    
    
    • 3
      @ 2021-5-3 7:40:50

      我来写一个Python题解。

      a,b=map(int,input().split())#读入变量a、b,以空格隔开,并转为整型(int)
      print(a+b)#输出a+b的值
      

      不得不说Python是真心简单

      • 2
        @ 2021-5-1 13:43:27

        C++

        #include <cstdio>
        #include <algorithm>
        #include <iostream>
        
        using namespace std;
        
        int main(void)
        {
            int a, b;
            scanf("%d%d", &a, &b);
            printf("%d\n", a + b);
            // cin >> a >> b;
            // cout << a + b;
            return 0;
        }
        
        • 0
          @ 2023-10-26 19:37:49
          #include<bits/stdc++.h>
          using namespace std;
          int main(){
          	int a,b;scanf("%d%d",&a,&b);
          	printf("%d",a+b);
          	return 0;
          }
          
          • 0
            @ 2022-11-25 18:56:58

            非常简单的一道题,输出a+b的和即可,跟H1001一样

            代码:

            #include<cstdio>//C语言风格输入输出头文件
            int main(){ //主函数
                int a,b;//定义变量a和b
                scanf("%d%d",&a,&b);//输入a和b
                printf("%d",a+b);//输出a+b
                return 0; //返回值(一定要是0!)
            }
            
            • 0
              @ 2022-8-7 17:02:44

              水题一道。 这里大家可以看到世界各大语言的代码:

              C

              #include <stdio.h>
              
              int main()
              {
                  int a,b;
                  scanf("%d%d",&a,&b);
                  printf("%d\n", a+b);
                  return 0;
              }
              

              C++

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

              Pascal

              var a, b: longint;
              begin
                  readln(a,b);
                  writeln(a+b);
              end.
              

              Python

              s = input().split()
              print(int(s[0]) + int(s[1]))
              

              Java

              import java.io.*;
              import java.util.*;
              public class Main {
                  public static void main(String args[]) throws Exception {
                      Scanner cin=new Scanner(System.in);
                      int a = cin.nextInt(), b = cin.nextInt();
                      System.out.println(a+b);
                  }
              }
              

              PHP

              <?php
              $input = trim(file_get_contents("php://stdin"));
              list($a, $b) = explode(' ', $input);
              echo $a + $b;
              

              Ruby

              a, b = gets.split.map(&:to_i)
              print a+b
              

              Rust

              use std::io;
              
              fn main(){
                  let mut input=String::new();
                  io::stdin().read_line(&mut input).unwrap();
                  let mut s=input.trim().split(' ');
              
                  let a:i32=s.next().unwrap()
                             .parse().unwrap();
                  let b:i32=s.next().unwrap()
                             .parse().unwrap();
                  println!("{}",a+b);
              }
              

              Go

              package main
              
              import "fmt"
              
              func main() {
                  var a, b int
                  fmt.Scanf("%d%d", &a, &b)
                  fmt.Println(a+b)
              }
              
              • @ 2022-9-22 19:56:31

                第五个python后边那个不是叫jvav吗(

            • -1
              @ 2024-2-16 9:03:53

              #include <bits/stdc++.h> using namespace std;
              int main() {
              int a, b;
              cin >> a >> b;
              cout << a + b;
              return 0;
              }
              兄啊,这事给若至做的罢(恼

              • -1
                @ 2024-1-19 13:18:30

                A + B Probelm 氵到要死

                C++的入门题吧,输入 aabb,输出a+ba+b

                #include<bits/stdc++.h>
                using namespace std;
                int main(){
                    int a, b;
                    cin >> a >> b;
                    cout << a + b;
                    return 0;
                }
                
                • -1
                  @ 2023-6-28 17:01:38

                  c++版的:

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

                    太简单了 c++ AC code:

                    #include<bits/stdc++.h> //万能头
                    using namespace std; // 命名空间
                    int main() { //主函数main()
                        int a,b; //定义整数a和b
                        cin>>a>>b;//输入
                        cout<<a+b;//输出
                        return 0;//结束
                    }
                    
                    • -1
                      @ 2022-10-5 22:22:58

                      很水的题。

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

                      题目中说了a、b都小于100,所以开int就行。

                      • -5
                        @ 2022-5-7 12:28:18

                        #include <iostream>

                        using namespace std;

                        int main()

                        {

                        long long A,B;//不开long long 见祖宗

                        cin>>A>>B;

                        cout<<A+B;

                        return 0;//不要我多讲了吧

                        }

                        球球了,点个👍吧,小哥哥帅气,小姐姐漂亮

                        • -5
                          @ 2021-5-19 21:37:08

                          C++11の高端的题解!

                          #include<iostream>
                          #include<cstdio>
                          #include<algorithm>
                          #include<cstring>
                          #include<cmath>
                          #include<string>
                          #include<cstdlib>
                          using namespace std;//超长无关紧要的高端的头文件
                          int a,b;//定义高端的变量
                          int main(){
                          	scanf("%d%d",&a,&b);//快速读入高端的变量
                          	printf("%d",a+b);//经过简简单单的高端的计算后,快速输出高端的结果!
                          	return 0;//高端而潇洒的结尾~
                          }
                          

                          看这高端的注释,不点个赞吗?

                          • -9
                            @ 2021-9-17 19:56:02

                            来一发dijkstra题解

                            #include<bits/stdc++.h>
                            using namespace std;
                            int n,m,s;
                            int head[100010],cnt=-1;
                            bool done[100010]={0};
                            long long ans[100010];
                            struct edge
                            {
                                int to,next,w;
                            }e[200010];
                            void add(int u,int v,int w)
                            {
                                e[++cnt].next=head[u];
                                head[u]=cnt;
                                e[cnt].to=v,e[cnt].w=w;
                            }
                            struct node
                            {
                                long long num,value;
                                bool operator <(const node &x) const{return value>x.value;}
                                node(long long num_,long long value_):num(num_),value(value_){}
                            };
                            priority_queue<node>dis;
                            void dijkstra()
                            {
                                while(!dis.empty())
                                {
                                    node u=dis.top();
                                    dis.pop();
                                    if(done[u.num]==1)continue;
                                    done[u.num]=1;
                                    ans[u.num]=u.value;
                                    for(int i=head[u.num];~i;i=e[i].next)
                                    {
                                        int v=e[i].to;
                                        if(done[v])continue;
                                        dis.push(node(v,u.value+e[i].w));
                                    }
                                }
                            }
                            int main()
                            {
                                int a,b;
                                cin>>a>>b;
                                n=3,m=2,s=1;
                                for(int i=1;i<=n;i++)
                                    head[i]=-1,dis.push(node(i,2147483647));
                                add(1,2,a),add(2,3,b);
                                dis.push(node(s,0));
                                dijkstra();
                                cout<<ans[3]<<endl;
                                return 0;
                            }
                            
                            • 1

                            信息

                            ID
                            1000
                            时间
                            1000ms
                            内存
                            256MiB
                            难度
                            1
                            标签
                            (无)
                            递交数
                            650
                            已通过
                            430
                            上传者