166 条题解

  • -2
    @ 2023-3-3 18:49:59

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

    #include <stdio.h>
    
    int main()
    {
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d\n", a+b);
        return 0;
    }
    
    • -2
      @ 2022-12-29 10:55:08

      非常简单的一道题,代码:

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

      注意pascal用integer会爆掉。

      • -2
        @ 2022-12-3 11:34:28
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
             int a,b;
             scanf("%d%d",&a,&b);
             return !printf("%d",a+b);
        }
        
        • -2
          @ 2022-11-22 16:02:23
          #include <bits/stdc++.h>
          using namespace std;int a,b;int main(){cin>>a>>b;cout<<a+b<<endl;return 0;}
          
          • -2
            @ 2022-11-20 18:23:45

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

            代码:

            #include<cstdio>//C语言风格输入输出头文件
            int main(){ //主函数
                int a,b;//定义变量
                scanf("%d%d",&a,&b);//输入a和b
                printf("%d",a+b);//输出a+b
                return 0; //返回值
            }
            
            • -2
              @ 2022-6-19 11:30:22

              补充一个julialang题解

              a=parse(Int, readuntil(stdin, ' '))
              b=parse(Int, readline())
              print(a+b)
              
              • -2
                @ 2022-5-29 14:48:53

                好吧,同志们,我们就从这一题开始,向着大牛的路进发。 任何一个伟大的思想,都有一个微不足道的开始。

                #include<bits/stdc++.h>//万能头文件
                using namespace std;//使用标准命名空间
                int a,b;//定义整型变量a、b,也就是参与运算的两个数
                int main(){//主函数,程序在这里运行
                    cin>>a>>b;//标准输入
                    cout<<a+b;//标准输出
                    return 0;//返回值,主函数的返回值必须是0
                }
                
                • -2
                  @ 2022-5-19 20:26:54
                  #include<iostream>//建议用iostream
                  using namespace std;//使用标准命名空间
                  int main(){//主函数
                  	int a,b;
                  	cin>>a>>b;
                  	cout<<a+b;
                  	return 0;
                  }
                  
                  • -2
                    @ 2022-5-8 20:16:04

                    入门题,每个OIer入坑必做题

                    不废话,直接上代码!

                    C++:

                    ```
                    #include<iostream>
                    using namespace std;
                    int main(){
                        int a,b;//定义变量
                        cin>>a>>b;//输入
                        cout<<a+b<<endl;//计算,输出
                    }
                    ```
                    

                    python3:

                    # python3 要使用split函数,因为输入是一行两个数字,spilt函数可以把两个数字读取而不读取空格
                    a=input().split() 
                    print(int(a0])+int(a[1]))
                    
                    • -2
                      @ 2022-4-11 7:50:21
                      #include<bits/stdc++.h>
                      using namespace std;
                      int main(){
                        int a,b;
                        cin>>a>>b;
                        cout<<a+b;
                        return 0;
                      }
                      
                      • -2
                        @ 2022-3-26 0:01:54
                        //新手可看此贴
                        #include<bits/stdc++.h>
                        using namespace std;
                        long long a,b;//定义变量a,b
                        int main(){
                            cin>>a>>b;//将a,b输入
                            cout<<a+b;//将a,b的和输出
                            return 0;//主函数返回值为0
                        }
                        
                        • -2
                          @ 2022-2-27 14:12:10
                          #include <bits/stdc++.h>
                          #include <cstdio>
                          using namespace std;
                          
                          int main()
                          {
                              long long a, b;
                              
                              scanf("%d%d", &a, &b);
                          
                              printf("%d", a + b);
                          
                              return 0;
                          }
                          
                          • -3
                            @ 2023-8-31 23:04:01

                            C++ 式普通写法

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

                            高精度

                            #include<iostream>
                            
                            using namespace std;
                            
                            const int MAXN = 1e5 + 10;
                            
                            long long r;
                            int c;
                            char op;
                            
                            struct bigint{
                              long long len,sz[MAXN] = {0};
                            
                              long long &operator [] (long long a){
                                return sz[a];
                              }
                            
                              void input(){
                                string s;
                                cin >> s;
                                len = s.size();
                                for (int i = 0; i < len; i++){
                                  sz[i] = s[len - i - 1] - '0';
                                }
                              }
                            
                              void output(){
                                for (; len - 1 > 0 && !sz[len - 1]; len--){
                                }
                            
                                for (int i = len - 1; i >= 0; i--){
                                  cout << sz[i];
                                }
                                cout << '\n';
                              }
                              bigint operator + (const bigint &b){
                                bigint c;
                                c.len = max(len,b.len) + 1;
                                for (int i = 0; i < c.len; i++){
                                  c[i] = sz[i] + b.sz[i];
                                }
                            
                                for (int i = 0; i < c.len - 1; i++){
                                  c[i + 1] += c[i] / 10,c[i] %= 10;
                                }
                                return c;
                              }
                            }a,b,ans;
                            
                            int main(){
                              a.input(),b.input();
                              ans = a + b;
                              ans.output();
                              return 0;
                            }
                            
                            • -3
                              @ 2023-7-18 18:53:00
                              #include <bits/stdc++.h>
                              using namespace std;
                              int main() {
                                  //以下三行为输入输出超大数据时标准输入输出流的加速
                                  ios::sync_with_stdio(false);
                                  cin.tie(0);
                                  cout.tie(0);
                                  long long a,b;
                                  cin>>a>>b;
                                  cout<<a+b<<endl;
                                  return 0;
                              }
                              
                              • -3
                                @ 2023-6-4 21:59:03
                                **#include** **<**bits**/**stdc**++.**h**>**
                                 **using** **namespace** **std**;
                                 **/\***
                                 **  **思路:将字符串s所有拆分的可能性都尝试一下
                                 **  **打擂台求出最小的素数
                                 ** **\*/
                                 
                                 //素数判断
                                 **bool** **sushu**(**int** **n**)** **{
                                 **    **for** **(**int** **i** **=** **2**;** **i** **<=** **sqrt**(**n**);** **i**++)** **{
                                 **        **if** **(**n** **%** **i** **==** **0**)** **{
                                 **            **return** **false**;**
                                 **        **}
                                 **    **}
                                 **    **if** **(**n** **<=** **1**)** **return** **false**;**
                                 **    **return** **true**;**
                                 }
                                 **int** **main**()** **{
                                 **    **string** **s**,** **s1**,** **s2**;**
                                 **    **int** **i**,** **mi** **=** **INT\_MAX**;** **//mi存储最小的素数
                                 **    **cin** **>>** **s**;**
                                 **    **int** **x**,** **y**;
                                 **    **/\*长度为s.size()的字符串,拆s.size()-1次
                                 **      **12345
                                 **      **i=0** **1** **2345** **s.substr(0,1)**  **s.substr(1)
                                 **      **i=1** **12** **345** **s.substr(0,2)**  **s.substr(2)
                                 **     **\*/
                                 **    **//循环拆段的次数
                                 **    **for** **(**i** **=** **0**;** **i** **<** **s**.**size**()** **-** **1**;** **i**++)** **{**
                                 **        **s1** **=** **s**.**substr**(**0**,** **i** **+** **1**);
                                 **        **s2** **=** **s**.**substr**(**i** **+** **1**);**
                                 **        **//cout<<s1<<"** **"<<s2<<endl;
                                 **        **x** **=** **atoi**(**s1**.**c\_str**());**
                                 **        **y** **=** **atoi**(**s2**.**c\_str**());**
                                 
                                 **        **if** **(**sushu**(**x** **+** **y**)** **&&** **x** **+** **y** **<** **mi**)** **mi** **=** **x** **+** **y**;
                                 **    **}
                                 **    **if** **(**mi** **==** **INT\_MAX**)** **cout** **<<** **-**1**;
                                 **    **else** **cout** **<<** **mi**;**
                                 **    **return** **0**;**
                                 }
                                
                                • -3
                                  @ 2023-4-8 20:33:53

                                  很简单,线段树模板题。

                                  #include <bits/stdc++.h>
                                  #define int long long
                                  using namespace std;
                                  int x, y, a[100005];
                                  struct node {
                                  	int l, r, w, tag;
                                  } tr[400005];
                                  inline bool inrange(int l1, int r1, int l2, int r2) {
                                  	return (l1 >= l2) && (r1 <= r2);
                                  }
                                  inline bool outofrange(int l1, int r1, int l2, int r2) {
                                  	return (l1 > r2) || (l2 > r1);
                                  }
                                  inline void pushup(int u) {
                                  	tr[u].w = tr[u * 2].w + tr[u * 2 + 1].w;
                                  }
                                  inline void build(int u, int l, int r) {
                                  	if (l == r) {
                                  		tr[u].w = a[l];
                                  		return;
                                  	}
                                  	int mid = l + r >> 1;
                                  	build(u * 2, l, mid); build(u * 2 + 1, mid + 1, r);
                                  	pushup(u);
                                  }
                                  inline int query1(int u, int l, int r, int p) {
                                  	if (l == r) {
                                  		return tr[u].w;
                                  	} else {
                                  		int mid = l + r >> 1;
                                  		if (p <= mid) return query1(u * 2, l, mid, p);
                                  		else return query1(u * 2 + 1, mid + 1, r, p);
                                  	}
                                  }
                                  inline void update1(int u, int l, int r, int p, int x) {
                                  	if (l == r) {
                                  		tr[u].w += x;
                                  	} else {
                                  		int mid = l + r >> 1;
                                  		if (mid >= p) update1(u * 2, l, mid, p, x);
                                  		else update1(u * 2 + 1, mid + 1, r, p, x);
                                  	}
                                  }
                                  inline void maketag(int u, int len, int x) {
                                  	tr[u].tag += x;
                                  	tr[u].w += len * x;
                                  }
                                  inline void pushdown(int u, int l, int r) {
                                  	int mid = l + r >> 1;
                                  	maketag(u * 2, mid - l + 1, tr[u].tag);
                                  	maketag(u * 2 + 1, r - mid, tr[u].tag);
                                  	tr[u].tag = 0;
                                  }
                                  inline int query(int u, int l1, int r1, int l2, int r2) {
                                  	if (inrange(l1, r1, l2, r2)) {
                                  		return tr[u].w;
                                  	} else if (!outofrange(l1, r1, l2, r2)) {
                                  		int mid = l1 + r1 >> 1;
                                  		pushdown(u, l1, r1);
                                  		return query(u * 2, l1, mid, l2, r2) + query(u * 2 + 1, mid + 1, r1, l2, r2);
                                  	}
                                  }
                                  inline void update(int u, int l1, int r1, int l2, int r2, int x) {
                                  	if (inrange(l1, r1, l2, r2)) {
                                  		maketag(u, r1 - l1 + 1, x);
                                  	} else if (!outofrange(l1, r1, l2, r2)) {
                                  		int mid = l1 + r1 >> 1;
                                  		pushdown(u, l1, r1);
                                  		update(u * 2, l1, mid, l2, r2, x);
                                  		update(u * 2 + 1, mid + 1, r1, l2, r2, x);
                                  		pushup(u);
                                  	}
                                  }
                                  signed main() {
                                      cin >> x >> y;
                                      build(1, 1, 1);
                                      update1(1, 1, 1, 1, x);
                                      update1(1, 1, 1, 1, y);
                                      cout << query1(1, 1, 1, 1);
                                      return 0;
                                  }
                                  
                                • -3
                                  @ 2023-3-20 15:48:05

                                  很简单,先用字符串存放数据,在从低位开始算,两两相加,逢十进一。

                                  ~代码才40行,不多~

                                  #include<bits/stdc++.h>
                                  using namespace std;
                                  int a[1000001],b[1000001],c[1000001],j;
                                  bool x=false;
                                  char s[1000001],ss[1000001];
                                  int main() 
                                  {
                                  	memset(a,0,sizeof(a));
                                  	memset(b,0,sizeof(b));
                                  	memset(c,0,sizeof(c));
                                  	scanf("%s%s",s,ss);
                                  	a[0]=strlen(s);
                                  	b[0]=strlen(ss);
                                  	for(int i=1; i<=a[0]; i++) 
                                  	a[i]=s[a[0]-i]-'0';
                                  	for(int i=1; i<=b[0]; i++) 
                                  	b[i]=ss[b[0]-i]-'0';
                                  	for(j=1; j<=max(a[0],b[0])+1; j++) 
                                  	{
                                  		c[j]=a[j]+b[j];
                                  		if(c[j]>=10) 
                                  		{
                                  			c[j]%=10;
                                  			a[j+1]++;
                                  		}
                                  	}
                                  	c[0]=j;
                                  	if(c[j+1]>0) c[0]++;
                                  	for(int i=c[0]; i>=1; i--) 
                                  	{
                                  		if(x==false&&c[i]==0) 
                                  		continue;
                                  		x=true;
                                  		cout<<c[i];
                                  	}
                                  	if(x==false) 
                                  	cout<<0;
                                  	printf("\n");
                                  	return 0;
                                  }
                                  

                                  管理员大大求过QAQ

                                  彩蛋

                                  文言版

                                  #及充窦融之女孙侍中垒兴矣。
                                  用命名为帝喾咨d
                                  甲戌,武军二千人[71]以五十吏二千人,吏二千人五十余年;
                                  &lt;
                                  甲戌,封府库二千二千余家,帝喾二千余家;
                                  &lt
                                  {
                                  更老女喜刑名。帝喾寿梦有子;
                                  更典帝喾嘉伯喈①,吾寿梦有子②;
                                  更典帝喾嘉伯喈。
                                  帝喾八月壬戌岂可怒哉!帝喾聿怀金玉,为帝喾次妃。
                                  [47]陈民典诰。
                                  [47]民义并行。
                                  猫一窦秋开二水中;
                                  [88]唐赛明之后[82]--][57]
                                  猫一窦秋开二水中;
                                  [88]唐广明年金涂海伯萧][57]-
                                  刘保好心,好梦回漠北;无如之何。
                                  {
                                  [88]刘宇深,[88];
                                  吾乃龌龊。
                                  {
                                  [88]徐卢=;
                                  [88]唐武爱吾;
                                  }
                                  }
                                  [88]
                                  [88]聚野草花,疏刑部伍胥靡];
                                  了窦融一窦通漾场;
                                  {
                                  若孝明旦唱为帝喾做成何人,
                                  引兵久之。
                                  蜥蜴_然;
                                  功名吟泽,无片云;
                                  }
                                  若(旦旦唱)
                                  co mán)42 30。
                                  乐则灵惨凄部(lya n.
                                  还。
                                  }
                                  
                                  • @ 2023-7-29 12:46:32

                                    a,b106a,b\le 10^6,用传统数据类型不能存吗?为什么用高精度加?

                                  • @ 2023-10-3 19:26:30

                                    @ 他炫技呗,别管这种人

                                • -3
                                  @ 2023-3-9 10:28:01

                                  这道题很简单

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

                                    很简单,适合刚学信息的同学。

                                    代码:

                                    
                                    
                                    #include<iostream>//头文件
                                    using namespace std;
                                    
                                    int main()//主函数
                                    {
                                    int a,b;//定义a和b
                                    cin>>a>>b;//输入
                                    cout<<a+b<<endl;//输出a+b并换行
                                    return 0;//程序结束后,返回0,也可以不写```}
                                    • -3
                                      @ 2023-2-26 10:43:36

                                      CODE:

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

                                      求赞!

                                      信息

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