28 条题解

  • 5
    @ 2023-11-25 19:21:55
    #include <iostream>
    using namespace std;
    #define ll long long
    const int N =1e5+10;
    const int INF =0x3f3f3f3f;
    string a,b;
    int a1[N],b1[N],c1[N],lena,lenb,lenc,x;
    int main()
    {
    	cin>>a>>b;
    	lena=a.size();
    	lenb=b.size();
    	for(int i=0;i<lena;i++)
    	{
    		a1[i]=a[lena-i-1]-'0';
    	}
    	for(int i=0;i<lenb;i++)
    	{
    		b1[i]=b[lenb-i-1]-'0';
    	}
    	lenc=max(lena,lenb);
    	for(int i=0;i<lenc;i++)
    	{
    		c1[i]=a1[i]+b1[i]+x;
    		x=c1[i]/10;
    		c1[i]%=10;
    	}
    	c1[lenc]=x;
    	while(c1[lenc]==0&&lenc>0)
    	{
    		lenc--;
    	}
    	for(int i=lenc;i>=0;i--)
    	{
    		cout<<c1[i];
    	}
     	return 0;
    }
    
    
    • 3

      全宇宙最简单老师教过的题的题解。点个赞吧,求求了!

      #include
      using namespace std;
      int c[600];
      int a1[510],b1[510];
      int len1,len2,len3,x;
      string a,b;
      int main(){
      cin>>a>>b;
      len1=a.size();
      len2=b.size();
      for(int i=0;i<len1;i++)a1[i]=a[len1-i-1]-'0';
      for(int i=0;i<len2;i++)b1[i]=b[len2-i-1]-'0';
      len3=max(len1,len2);
      for(int i=0;i<len3;i++){
      c[i]=a1[i]+b1[i]+x;
      x=c[i]/10;
      c[i]%=10;
      }
      c[len3]=x;
      while(c[len3]==0&&len3>0){
      len3--;
      }
      for(int i=len3;i>=0;i--)cout<<c[i];
      return 0;
      }
      
      • 3
        @ 2023-11-25 19:18:36

        #include<iostream> #include<string> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; string a,b; int lena,lenb,lenc,a1[N],b1[N],c1[N],z=0; int main(){ cin>>a>>b; lena=a.size(); lenb=b.size();

        for(int i=0;i<lena;i++)
        a1[i]=a[lena-i-1]-'0';
        
        for(int i=0;i<lenb;i++)
        b1[i]=b[lenb-i-1]-'0';
        
        lenc=max(lena,lenb);
        
        for(int i=0;i<lenc;i++)
        {
        	c1[i]=a1[i]+b1[i]+z;
        	z=c1[i]/10;
        	c1[i]%=10;
        }
        
        c1[lenc]=z;
        
        while(c1[lenc]==0&&lenc>0)
        lenc--;
        
        for(int i=lenc;i>=0;i--)
        cout<<c1[i];
        

        }

        • 1
          @ 2024-12-7 18:53:00

          #include<bits/stdc++.h> using namespace std; string a1,b1; int a[500],b[500],c[500]; int main(){ cin>>a1>>b1; int lena=a1.size(); int lenb=b1.size(); for(int i=1;i<=lena;i++)a[i]=a1[lena-i]-'0'; for(int i=1;i<=lenb;i++)b[i]=b1[lenb-i]-'0'; int lenc=1; while(lenc<=lena||lenc<=lenb){ c[lenc]+=a[lenc]+b[lenc]; if(c[lenc]>=10){ c[lenc]-=10; c[lenc+1]++; } lenc++; } lenc--; if(c[lenc+1]!=0)lenc++; for(int i=lenc;i>=1;i--)cout<<c[i]; return 0; }

          • 1

            // Anthony //<< fixed << setprecision (); //for ( int i = ;i <= ; i++) //printf ( "%6d" , a) //int = %d //longlong = %lld //fload = %f //double = %lf //char = %c //char[] = %s //"0" = 48 //"9" = 57 //"A" = 65 //"Z" = 90 //"a" = 97 //"z" = 122 //note: #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> #include <time.h> #include <unistd.h> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; string a , b; int lena , lenb , lenc , a1[N] , b1[N] , c1[N] , x; int main() { cin >> a >> b; lena = a.size(); lenb = b.size(); for ( int i = 0; i < lena; i++) { a1[i] = a[lena - i - 1] - '0'; } for ( int i = 0; i < lenb; i++) { b1[i] = b[lenb - i - 1] - '0'; } lenc = max ( lena , lenb); for ( int i = 0; i < lenc; i++) { c1[i] = a1[i] + b1[i] + x; x = c1[i] / 10; c1[i] %= 10; } c1[lenc] = x; while ( c1 [ lenc ] == 0 && lenc > 0) { lenc--; } for ( int i = lenc; i >= 0; i--) { cout << c1[i]; }

            return 0;
            

            }

            • 1
              @ 2023-11-25 19:22:15

              #include<iostream> #include<iomanip> #include<cmath> #include<cstring> #include<algorithm> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int a1[N],b1[N],c1[N],lena,lenb,lenc,x; string a,b; int main() { cin>>a>>b; lena=a.size(); lenb=b.size(); for(int i=0;i<lena;i++) { a1[i]=a[lena-i-1]-'0'; } for(int i=0;i<lenb;i++) { b1[i]=b[lenb-i-1]-'0'; } lenc=max(lena,lenb); for(int i=0;i<lenc;i++) { c1[i]=a1[i]+b1[i]+x; x=c1[i]/10; c1[i]%=10; } c1[lenc]=x; while(c1[lenc]==0&&lenc>0) lenc--; for(int i=lenc;i>=0;i--) { cout<<c1[i]; }

              return 0; }

              • 1
                @ 2023-11-25 19:20:56
                #include <iostream>
                #include <iomanip>
                #include <cmath>
                #include <string>
                #include <cstring>
                #include <algorithm>
                #include <cstdio>
                using namespace std;
                const int N = 1e5+10;
                string a , b;
                int a1[N] , b1[N] , c1[N] , lena , lenb , lenc , x;
                int main()
                {
                	cin>>a >>b;
                	lena = a.size();
                	lenb = b.size();
                	for(int i = 0;i < lena;i++)
                	{
                		a1[i] = a[lena - i - 1] - '0';
                	}
                	for(int i = 0;i < lenb;i++)
                	{
                		b1[i] = b[lenb - i - 1] - '0';
                	}
                	lenc  = max(lena , lenb);
                	for(int i = 0 ; i < lenc;i++)
                	{
                		c1[i] = a1[i] + b1[i] + x;
                		x = c1[i] / 10;
                		c1[i] %= 10;
                	}
                	c1[lenc] = x;
                	while(c1[lenc] == 0 &&lenc > 0)
                	{
                		lenc--;
                	}
                	for(int i = lenc; i >= 0;i--)
                	{
                		cout<<c1[i];
                	}
                	return 0;
                }
                
                • 0
                  @ 2024-12-7 18:52:30

                  #include<bits/stdc++.h> using namespace std; string a1,b1; int a[500],b[500],c[500]; int main(){ cin>>a1>>b1; int lena=a1.size(); int lenb=b1.size(); for(int i=1;i<=lena;i++)a[i]=a1[lena-i]-'0'; for(int i=1;i<=lenb;i++)b[i]=b1[lenb-i]-'0'; int lenc=1; while(lenc<=lena||lenc<=lenb){ c[lenc]+=a[lenc]+b[lenc]; if(c[lenc]>=10){ c[lenc]-=10; c[lenc+1]++; } lenc++; } lenc--; if(c[lenc+1]!=0)lenc++; for(int i=lenc;i>=1;i--)cout<<c[i]; return 0; }

                  • 0
                    @ 2024-10-15 17:19:02
                    #include <bits/stdc++.h>
                    using namespace std;
                    string a,b;
                    int a1[510],b1[510],c1[510],lena,lenb,lenc;
                    int x;
                    
                    int main(){
                    	cin>>a>>b;
                    	lena=a.size();
                    	lenb=b.size();
                    	for(int i=0;i<lena;i++){
                    		a1[i]=a[lena-i-1]-'0';
                    	}
                    	for(int i=0;i<lenb;i++){
                    		b1[i]=b[lenb-i-1]-'0';
                    	}
                    	lenc=max(lena-1,lenb-1);
                    	for(int i=0;i<=lenc;i++){
                    		c1[i]=a1[i]+b1[i]+x;
                    		x=c1[i]/10;
                    		c1[i]%=10;
                    	}
                    	c1[++lenc]=x;
                    	while(c1[lenc]==0&&lenc>0){
                    		lenc--;
                    	}
                    	for(int i=lenc;i>=0;i--){
                    		cout<<c1[i];
                    	}
                    	return 0;
                    }
                    
                    
                    
                    
                    • 0
                      @ 2024-10-15 17:03:53
                      #include <iostream>
                      using namespace std;
                      string a,b;
                      int a1[520],b1[520],c1[520],lena,lenb,lenc,x;
                      int main()
                      {
                      	cin>>a>>b;
                      	lena=a.size();
                      	lenb=b.size();
                      	for(int i=0;i<lena;i++)
                      	{
                      		a1[i]=a[lena-i-1]-'0';
                      	}
                      	for(int i=0;i<lenb;i++)
                      	{
                      		b1[i]=b[lenb-i-1]-'0';
                      	}
                      	lenc=max(lena,lenb);
                      	for(int i=0;i<lenc;i++)
                      	{
                      		c1[i]=a1[i]+b1[i]+x;
                      		x=c1[i]/10;
                      		c1[i]%=10;
                      	}
                      	c1[lenc]=x;
                      	while(c1[lenc]==0&&lenc>0)
                      	{
                      		lenc--;
                      	}
                      	for(int i=lenc;i>=0;i--)
                      	{
                      		cout<<c1[i];
                      	}
                       	return 0;
                      }
                      
                      
                      
                      • 0
                        @ 2024-3-17 14:50:12

                        #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; string a , b; int lena , lenb , lenc , a1[N] , b1[N] , c1[N] , x; int main() { cin >> a >> b; lena = a.size(); lenb = b.size(); for (int i = 0 ; i <= lena ; i++){ a1[i] = a[lena - i - 1] - '0'; } for (int i = 0 ; i <= lenb ; i++){ b1[i] = b[lenb - i - 1] - '0'; } lenc = max(lena , lenb); for (int i = 0 ; i <= lenc ; i++){ c1[i] = a1[i] + b1[i] + x; x = c1[i] / 10; c1[i] %= 10; } c1[lenc] = x; while (c1[lenc] == 0 && lenc > 0){ lenc--; } for (int i = lenc ; i >= 0 ; i--){ cout << c1[i]; }

                        return 0;
                        

                        }

                        • 0
                          @ 2023-11-29 18:25:10
                          #include <iostream>
                          using namespace std;
                          #define ll long long
                          const int N =1e5+10;
                          const int INF =0x3f3f3f3f;
                          string a,b;
                          int a1[N],b1[N],c1[N],lena,lenb,lenc,x;
                          int main()
                          {
                          	cin>>a>>b;
                          	lena=a.size();
                          	lenb=b.size();
                          	for(int i=0;i<lena;i++)
                          	{
                          		a1[i]=a[lena-i-1]-'0';
                          	}
                          	for(int i=0;i<lenb;i++)
                          	{
                          		b1[i]=b[lenb-i-1]-'0';
                          	}
                          	lenc=max(lena,lenb);
                          	for(int i=0;i<lenc;i++)
                          	{
                          		c1[i]=a1[i]+b1[i]+x;
                          		x=c1[i]/10;
                          		c1[i]%=10;
                          	}
                          	c1[lenc]=x;
                          	while(c1[lenc]==0&&lenc>0)
                          	{
                          		lenc--;
                          	}
                          	for(int i=lenc;i>=0;i--)
                          	{
                          		cout<<c1[i];
                          	}
                           	return 0;
                          }
                          
                          • 0
                            @ 2023-11-29 18:24:53

                            #include<iostream> #include<string> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; string a,b; int lena,lenb,lenc,a1[N],b1[N],c[N],z; int main(){ cin>>a>>b; lena=a.size(); lenb=b.size();

                            for(int i=0;i<lena;i++)
                            a1[i]=a[lena-i-1]-'0';
                            
                            for(int i=0;i<lenb;i++)
                            b1[i]=b[lenb-i-1]-'0';
                            
                            lenc=max(lena,lenb);
                            
                            for(int i=0;i<lenc;i++)
                            {
                            	c[i]=a1[i]+b1[i]+z;
                            	z=c[i]/10;
                            	c[i]%=10;
                            }
                            
                            c[lenc]=z;
                            
                            while(c[lenc]==0&&lenc>0)
                            lenc--;
                            
                            for(int i=lenc;i>=0;i--)
                            cout<<c[i];
                            

                            }

                            • 0
                              @ 2023-11-29 18:24:53

                              #include<iostream> #include<string> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; string a,b; int lena,lenb,lenc,a1[N],b1[N],c[N],z; int main(){ cin>>a>>b; lena=a.size(); lenb=b.size();

                              for(int i=0;i<lena;i++)
                              a1[i]=a[lena-i-1]-'0';
                              
                              for(int i=0;i<lenb;i++)
                              b1[i]=b[lenb-i-1]-'0';
                              
                              lenc=max(lena,lenb);
                              
                              for(int i=0;i<lenc;i++)
                              {
                              	c[i]=a1[i]+b1[i]+z;
                              	z=c[i]/10;
                              	c[i]%=10;
                              }
                              
                              c[lenc]=z;
                              
                              while(c[lenc]==0&&lenc>0)
                              lenc--;
                              
                              for(int i=lenc;i>=0;i--)
                              cout<<c[i];
                              

                              }

                              • 0
                                @ 2023-11-25 19:23:07

                                #include <bits/stdc++.h> using namespace std; int a1[100005], b1[100005], c1[100005], x; int main() { string a,b; cin >> a >> b; int lena = a.size(); int lenb = b.size(); for (int i = 0; i < lena; i++) { a1[i] = a[lena - i - 1] - '0'; } for (int i = 0; i < lenb; i++) { b1[i] = b[lenb - i - 1] - '0'; } int lenc = max(lena, lenb); for (int i = 0; i < lenc; i++) { c1[i] = a1[i] + b1[i] + x; x = c1[i] / 10; c1[i] %= 10; } c1[lenc] = x; while (c1[lenc] == 0 && lenc > 0) { lenc--; } for (int i = lenc; i >= 0; i--) { cout << c1[i]; } return 0; }

                                • 0
                                  @ 2023-10-29 19:45:31
                                  #include<iostream>
                                  #include<string.h>
                                  using namespace std;
                                  const int INF=0x3f3f3f3f;
                                  const int N=2e5+10;
                                  string a,b;
                                  int lena,lenb,lenc,a1[N],b1[N],c1[N],x; 
                                  int main(){
                                  	cin>>a>>b;
                                  	lena=a.size();
                                  	lenb=b.size();
                                  	for(int i=0;i<lena;i++){
                                  		a1[i]=a[lena-i-1]-'0';
                                  	}
                                  	for(int i=0;i<lenb;i++){
                                  		b1[i]=b[lenb-i-1]-'0';
                                  	}
                                  	lenc=max(lena,lenb);
                                  	for(int i=0;i<=lenc;i++){
                                  		c1[i]=a1[i]+b1[i]+x;
                                  		x=c1[i]/10;
                                  		c1[i]%=10;
                                  	}
                                  	while(c1[lenc]==0&&lenc>0){
                                  		lenc--;
                                  	}
                                  	for(int i=lenc;i>=0;i--){
                                  		cout<<c1[i];
                                  	}
                                  }
                                  
                                  • 0
                                    @ 2023-10-29 18:13:08
                                    #include <bits/stdc++.h>//114514廖浩宇 
                                    using namespace std;
                                    int a1[501],b1[501],c1[501];//初始化 
                                    int lia,lsb;
                                    string sb1,sb2;
                                    int main(){
                                    	cin >> sb1 >> sb2;//我劝你给我点个赞 
                                    	lia=sb1.size();
                                    	lsb=sb2.size();
                                    	for (int i = 0; i < lia; i++)
                                    		a1[lia-i] = sb1[i] - '0';
                                    	for (int i = 0; i < lsb; i++)
                                    		b1[lsb-i] = sb2[i] - '0';
                                    	int lcp = max(lia,lsb) + 1;
                                    	for (int i = 1; i <= lcp; i++)
                                    	{
                                    		c1[i] += a1[i] + b1[i];
                                    		c1[i+1] = c1[i] / 10;
                                    		c1[i] %= 10;
                                    	}
                                    	while(c1[lcp] == 0 && lcp > 1)
                                    		lcp--;
                                    	for (int i = lcp; i >= 1; i--)
                                    		cout << c1[i];  
                                    }
                                    
                                    
                                    • -1
                                      #include<iostream>
                                      using namespace std;
                                      
                                      const int N = 1e5 + 10;
                                      string a , b;
                                      int a1[N] , b1[N] , c1[N] , lena , lenb , lenc , x;
                                      
                                      int main(){
                                      	cin >> a >> b;
                                      	lena = a.size();
                                      	lenb = b.size();
                                      	lenc = max(lena , lenb);
                                      	for(int i = 0;i < lena;i ++){
                                      		a1[i] = a[lena - i - 1] - '0';
                                      	}for(int i = 0;i < lenb;i ++){
                                      		b1[i] = b[lenb - i - 1] - '0';
                                      	}for(int i = 0;i < lenc;i ++){
                                      		c1[i] = a1[i] + b1[i] + x;
                                      		x = c1[i] / 10;
                                      		c1[i] %= 10;
                                      	}
                                      	c1[lenc] = x;
                                      	while(c1[lenc] == 0 && lenc > 0){
                                      		lenc --;
                                      	}for(int i = lenc;i >= 0;i --){
                                      		cout << c1[i];
                                      	}
                                      	return 0;
                                      }
                                      
                                      • -1

                                        #include<bits/stdc++.h> using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; char a[N],b[N]; int a1[N],b1[N],c1[N],lenc,x; int main(){ cin>>a>>b; int lena=strlen(a); int lenb=strlen(b); for(int i=0;i<lena;i++) a1[i]=a[lena-i-1]-'0'; for(int j=0;j<lenb;j++) b1[j]=b[lenb-j-1]-'0';

                                        lenc=max(lena,lenb);
                                        for(int i=0;i<lenc;i++){
                                        	c1[i]=a1[i]+b1[i]+x;
                                        	x=c1[i]/10;
                                        	c1[i]%=10;
                                        }
                                        c1[lenc]=x;
                                        while(c1[lenc]==0&&lenc>0)
                                        	lenc--;
                                        
                                        for(int i=lenc;i>=0;i--){
                                        	cout<<c1[i];
                                        	
                                        }
                                        return 0;
                                        

                                        }

                                        • -1
                                          @ 2023-5-2 20:55:19
                                          #include<iostream>
                                          using namespace std;
                                          string s1,s2;
                                          int a[505],b[505],c[505];
                                          int la,lb;
                                          int main()
                                          {
                                          	cin >> s1 >> s2;
                                          	la = s1.size();
                                          	lb = s2.size();
                                          	for(int i = 0; i < la;i++) a[la - i] = s1[i] - '0';
                                          	for(int i = 0; i < lb;i++) b[lb - i] = s2[i] - '0';
                                          	int lc = max(la,lb)+1;
                                          	for(int i=1;i <= lc;i++)
                                          	{
                                          		c[i] += a[i] +b[i];
                                          		c[i + 1 ] = c[i]/10;\
                                          		c[i] %= 10;
                                          	}
                                          	while(c[lc] == 0 && lc > 1)lc--;
                                          	for(int i = lc; i >= 1; i--) cout << c[i];
                                          	return 0;
                                          }
                                          

                                          信息

                                          ID
                                          1190
                                          时间
                                          1000ms
                                          内存
                                          128MiB
                                          难度
                                          7
                                          标签
                                          递交数
                                          1081
                                          已通过
                                          274
                                          上传者