14 条题解

  • 12
    @ 2023-8-27 21:05:18

    这道世界难题真的太难辣!今天才发现一年前的题解有误,以下是正确题解:

    // C
    
    #ifndef _GLIBCXX_NO_ASSERT
    #include <cassert>
    #endif
    #include <cctype>
    #include <cerrno>
    #include <cfloat>
    #include <ciso646>
    #include <climits>
    #include <clocale>
    #include <cmath>
    #include <csetjmp>
    #include <csignal>
    #include <cstdarg>
    #include <cstddef>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    
    #if __cplusplus >= 201103L
    #include <ccomplex>
    #include <cfenv>
    #include <cinttypes>
    #include <cstdalign>
    #include <cstdbool>
    #include <cstdint>
    #include <ctgmath>
    #include <cuchar>
    #include <cwchar>
    #include <cwctype>
    #endif
    
    // C++
    #include <algorithm>
    #include <bitset>
    #include <complex>
    #include <deque>
    #include <exception>
    #include <fstream>
    #include <functional>
    #include <iomanip>
    #include <ios>
    #include <iosfwd>
    #include <iostream>
    #include <istream>
    #include <iterator>
    #include <limits>
    #include <list>
    #include <locale>
    #include <map>
    #include <memory>
    #include <new>
    #include <numeric>
    #include <ostream>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdexcept>
    #include <streambuf>
    #include <string>
    #include <typeinfo>
    #include <utility>
    #include <valarray>
    #include <vector>
    
    #if __cplusplus >= 201103L
    #include <array>
    #include <atomic>
    #include <chrono>
    #include <codecvt>
    #include <condition_variable>
    #include <forward_list>
    #include <future>
    #include <initializer_list>
    #include <mutex>
    #include <random>
    #include <ratio>
    #include <regex>
    #include <scoped_allocator>
    #include <system_error>
    #include <thread>
    #include <tuple>
    #include <typeindex>
    #include <type_traits>
    #include <unordered_map>
    #include <unordered_set>
    #endif
    
    #if __cplusplus >= 201402L
    #include <shared_mutex>
    #endif
    
    using namespace std;
    long long aNumberAndNameIsA;
    long long aNumberAndNameIsB;
    long long aNumberAndNameIsAnswer;
    bool check(long long aNumberAndNameIsA__, long long aNumberAndNameIsB__) {
    	if (aNumberAndNameIsA__ + aNumberAndNameIsB__)
    		return true;
    }
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	while (cin >> aNumberAndNameIsA >> aNumberAndNameIsB) {
    		if (check(aNumberAndNameIsA, aNumberAndNameIsB))
    			aNumberAndNameIsAnswer = aNumberAndNameIsA + aNumberAndNameIsB;
    		cout << aNumberAndNameIsAnswer << "\n";
    	}
    	return 0;
    }
    
    • @ 2023-8-27 21:06:05

      doge(((

    • @ 2023-10-4 12:11:29

      9

    • @ 2024-2-13 19:52:03

      (0_0)

    • @ 2024-2-26 21:01:55

      what!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    • @ 2024-3-3 9:55:40

      ??? doge👀️

    • @ 2024-4-3 16:44:36

      这就是中国牌火车头的力量吗?膜拜!

    • @ 2024-5-3 11:34:11

      @ #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <complex> #include <csignal> #include <csetjmp> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <cwchar> #include <cwctype> #include <deque> #include <exception> #include <fstream> #include <functional> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector>

    • @ 2024-6-1 17:41:24

      下次请用万能头

    • @ 2024-6-8 17:16:34

      ??666

  • 7
    @ 2022-8-6 20:31:37
    #include<bits/stdc++.h>
    using namespace std;
    long long a,b; // 真·不开long long见祖宗
    int main(){
        ios::sync_with_stdio(false); // 输入输出加速
        cin.tie(0);
        cout.tie(0);
        while(cin>>a>>b){ // 读取到文件结尾
            cout<<a+b<<"\n";
        }
        return 0;
    }
    
    • @ 2023-5-13 18:42:24

      #include <bits/stdc++.h> using namespace std; long long a, b; int main() { ios::sync_with_stdio(false); cin.tie(0); while (cin >> a >> b) cout << a + b << "\n"; return 0; }

    • @ 2023-5-13 18:42:38
      #include <bits/stdc++.h>
      using namespace std;
      long long a, b;
      int main()
      {
          ios::sync_with_stdio(false);
          cin.tie(0);
          while (cin >> a >> b)
              cout << a + b << "\n";
          return 0;
      }
      
  • 5
    @ 2023-7-8 17:34:21
    #include <bits/stdc++.h>
    #define ll long long
    int main()
    {
        ll a, b;
        while (std::cin >> a >> b)
            std::cout << a + b << "\n";
        return 0;
    }
    
    • 5
      @ 2021-8-28 11:47:58

      数据类型对应的范围可以查看 https://oi-wiki.org/lang/var/

      读取到文件结尾的方式有很多种,文件结尾的符号 EOF 实际上对应的就是 -3,如果 scanf 读取到文件结尾就会返回 EOF,否则会返回成功输入了多少个元素。因此如果使用 scanf 可以这么做:

      while(scanf("%lld%lld",&a,&b)!=EOF){ ... }
      while(~scanf("%lld%lld",&a,&b)){ ... }
      while(scanf("%lld%lld",&a,&b)!=-1){ ... }
      

      cin 的返回值比较特殊,可以简单理解为如果读到文件结尾返回值对应的布尔值就是假

      因此如果使用 cin,可以这么做:

      while (cin >> a >> b)
      
      • 3
        @ 2023-12-9 12:32:59
        #include <bits/stdc++.h> 
        using namespace std;
        long long a,b;
        int main(){
            while(cin>>a>>b)
                cout<<a+b<<endl;}
        
        • 2
          @ 2023-9-4 20:37:45

          使用处理异常功能完成这道题

          众所周知python有一个try-except语法,用来截获并处理程序异常.用法如下:

          try:
              A
          except xxxError:
              B
          

          程序会执行A段代码,如果引发了xxxError则执行B段代码.


          再回头看这道题,题目数据范围中有说“输入a,b的组数不超过10”,所以可以直接循环10次,每次输入a和b,输出相加的结果即可.就像这样:

          for i in range(10):
              a, b = tuple(map(int, input().split()))
              print(a+b)
          

          显然的,这样会引发EOFError.那刚刚学的try-except不就派上用场了嘛,如果引发EOFError就说明输入没了,就可以直接break了,代码如下:

          for i in range(10):
              try:
                  a, b = tuple(map(int, input().split()))
                  print(a+b)
              except EOFError:
                  break
          
          • 2
            @ 2023-7-24 16:04:47

            #include<bits/stdc++.h> using namespace std; long long a,b; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); while(cin>>a>>b){ cout<<a+b<<"\n"; } return 0; }

            • 2
              @ 2023-7-7 12:52:08
              #include<bits/stdc++.h>
              using namespace std;
              long long a,b; 
              int main(){
                  ios::sync_with_stdio(false); //加速
                  cin.tie(0);
                  cout.tie(0);
                  while(cin>>a>>b){ 
                      cout<<a+b<<"\n";
                  }
                  return 0;
              }
              
              • 2
                @ 2023-4-30 8:30:15

                HT1078 A+B

                注意

                1.long long

                2.while(cin >> a >> b)


                参考代码:

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

                hetao3097453

                2023年4月30日

                • 1
                  @ 2023-4-29 13:14:54
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      long long a, b;
                      cin >> a >> b;
                      cout << a + b << endl;
                      long long n = a, m = b;
                      for (int i = 2; i <= 10; i++)
                      {
                          cin >> a >> b;
                          if (a == n && b == m)
                          {
                              continue;
                          }
                          cout << a + b << endl;
                          n = a, m = b;
                      }
                      return 0;
                  }
                  
                  • 0
                    @ 2023-11-4 21:48:28

                    言简意赅的题解~~~

                    时间 掌握程度 心情 做题方法
                    2023.11.4 (^_^) 用一个数加另一个数
                    • @ 2023-11-24 12:48:41

                      是把他们的绝对值相加

                    • @ 2023-11-24 12:53:20
                      时间 掌握程度 做题方法 心情
                      2023.11.24 把他们的绝对值相加 (^_^)
                  • -2
                    @ 2023-10-11 16:27:27

                    简单的高精度加法

                    • -3
                      @ 2021-8-27 10:38:45

                      请注意:不要在 8 月 28 日 10:30 之前发布本题任何形式的题解,否则你的题解可能会被删除!

                      • @ 2022-12-1 21:21:07

                      • @ 2022-12-1 21:21:14

                        @

                      • @ 2022-12-1 21:21:24
                      • @ 2023-11-24 12:54:17

                        ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

                    • -6
                      @ 2022-4-24 16:58:28

                      写题解请注意

                      鼓励大家写题解,但注意题解格式。

                      题解一定要有思路解析或代码注释,能否让别人理解你的思路

                      也是你的能力的检验,不要只放无意义的代码给大家复制,那就失去了做题的初心。

                      给代码两端加上这个会舒服一些

                      ```cpp

                      你的代码

                      ```

                      </span>

                      这个点在键盘的左上角tab上面那个键,注意切换输入法

                      #include<iostream>
                      using namespace std;
                      int main()
                      {
                          int n;
                          cin>>n;//这是一个注释
                          return 0;
                      } 
                      

                      请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                      抄袭题解一经发现直接取消成绩。

                      题解被删除的可能

                      1. 代码不符合格式规范
                      2. 没有思路讲解或者没有注释,
                      3. 无意义的题解

                      大家携手共同维护一个良好的编程环境,如果一经发现,多次作乱。可能会被管理员拉黑,请注意,一旦拉黑即失去登陆资格。

                      • 1

                      信息

                      ID
                      1230
                      时间
                      1000ms
                      内存
                      256MiB
                      难度
                      4
                      标签
                      递交数
                      739
                      已通过
                      323
                      上传者