23 条题解

  • 9
    @ 2021-11-13 20:36:14
    /*****************************************
    备注:
    ******************************************/
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    #define LL long long
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    int x[N] ,y[N];
    int main()
    {
    	string a,b;
    	int flag = 0;
    	cin >> a >> b;
    	int lena = a.size();
    	int lenb = b.size();
    	if(lenb > lena )
    		flag = 1;
    	if(lena == lenb && b > a)
    		flag = 1;
    	if(flag)
    	{
    		swap(a,b);
    		swap(lena, lenb);
    		cout << "-";
    	}
    	for(int i = 0 ; i < lena ; i++)
    		x[i] = a[lena - i - 1] - '0';
    	for(int i = 0 ; i < lenb ; i++)
    		y[i] = b[lenb - i - 1] - '0';
    
    	for(int i = 0 ; i < lena ; i++)
    	{
    		x[i] -= y[i];
    		if(x[i] < 0)
    		{	
    			x[i] += 10;
    			x[i+1]--;
    		}
    	}
    	while(x[lena] == 0 && lena > 0)
    		lena--;
    	for(int i = lena ; i >= 0 ; i--)
    		cout << x[i];
    	return 0;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    • 3
      @ 2021-11-6 20:56:50
      #include <stdio.h>
      
      #include <iostream>
      
      #include <math.h> 
      
      #include <string.h>
      
      using namespace std;
      
      int main()
      
      {
      
      	char aa[1005],bb[1005],cc[1005];
      
      	cin >> aa >> bb;
      
      	int lena = strlen(aa);
      
      	int lenb = strlen(bb);
      
      	int flag = 0;
      
      	if(lena < lenb)
      
      		flag = 1;
      
      	else if(lena == lenb && strcmp(aa,bb) < 0)
      
      		flag = 1;
      
      	if(flag)
      
      	{
      
      		strcpy(cc,aa);
      
      		strcpy(aa,bb);
      
      		strcpy(bb,cc);
      
      		swap(lena,lenb);
      
      		cout << "-";
      
      	}
      
      	int a[1090],b[1004],c[1005];
      
      	memset(a,0,sizeof(a));
      
      	memset(b,0,sizeof(b));
      
      	memset(c,0,sizeof(c));
      
      	for(int i = 0 ; i < lena ; i++)
      
      		a[i] = aa[lena - i - 1] - '0';
      
      	for(int i = 0 ; i < lenb ; i++)
      
      		b[i] = bb[lenb - i - 1] - '0';
      
      	for(int i = 0 ; i < lena ; i++)
      
      	{
      
      		c[i] = a[i] - b[i];
      
      		if(c[i] < 0)
      
      		{
      
      			c[i] += 10;
      
      			a[i+1]--;
      
      		}
      
      	}
      
      	int len = lena ;
      
      	while(len > 0 && c[len] == 0)
      
      		len--;
      
      	for(int i = len ; i >= 0 ; i--)
      
      		cout << c[i];
      
      }
      
      • 1
        @ 2023-11-29 18:23:37
        #include<iostream>
        #include<cstdio>
        #include<cmath>
        #include<algorithm>
        #include<string>
        #include<cstring>
        const int INF=0x3f3f3f3f;
        const int N=1e5+10;
        using namespace std;
        string a,b;
        int a1[N],b1[N],c1[N],lena,lenb,lenc;
        int main(){
        	cin>>a>>b;
        	lena=a.size();
        	lenb=b.size();
        	if(lena<lenb||(lena == lenb&&a<b))
        	{
        		swap(lena,lenb);
        		swap(a,b);
        		cout<<"-";
        	}
        	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 =lena;
        		for(int i =0;i<lenc;i++)
        		{
        			c1[i]=a1[i]-b1[i];
        			if(c1[i]<0)
        			{
        				a1[i+1]--;
        				c1[i] += 10;
        			}
        		}
        		while(c1[lenc]==0&&lenc>0)
        		lenc--;
        		
        		for(int i=lenc;i>=0;i--)
        		cout<<c1[i];
        	return 0;
        }
        
        • 0
          @ 2024-12-6 18:24:12
          #include<bits/stdc++.h>
          using namespace std;
          const int N=1e5+10;
          int x[N],y[N],z[N];
          char a[10000],b[10000];
          int main(){
          	cin>>a>>b;
          	int len1=strlen(a);
          	int len2=strlen(b);
          	int flag=0;
          	if(len1<len2){
          		flag=1;
          	}
          	if(len1==len2&&strcmp(a,b)<0){
          		flag=1;
          	}
          	if(flag){
          		swap(len1,len2);
          		swap(a,b);
          		cout<<"-";
          	}
          	for(int i=0;i<len1;i++){
          		x[i]=a[len1-i-1]-'0';
          	}
          	for(int i=0;i<len2;i++){
          		y[i]=b[len2-i-1]-'0';
          	}
          	for(int i=0;i<len1;i++){
          		z[i]+=x[i]-y[i];
          		if(z[i] < 0){	
          			z[i] += 10;
          			z[i+1]-=1;
          		}
          	}
          	while(z[len1] == 0 && len1 > 0){
          		len1--;
          	}
          		
          	for(int i=len1;i>=0;i--){
          		cout<<z[i];
          	}
          	return 0;
          }
          
          • -1
            @ 2023-11-25 19:49:38

            #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> const int INF=0x3f3f3f3f; const int N=1e5+10; using namespace std; string a,b; int a1[N],b1[N],c1[N],lena,lenb,lenc; int main(){ cin>>a>>b; lena=a.size(); lenb=b.size(); if(lena<lenb||(lena == lenb&&a<b)) { swap(lena,lenb); swap(a,b); cout<<"-"; } 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 =lena; for(int i =0;i<lenc;i++) { c1[i]=a1[i]-b1[i]; if(c1[i]<0) { a1[i+1]--; c1[i] += 10; } } while(c1[lenc]==0&&lenc>0) lenc--;

            	for(int i=lenc;i>=0;i--)
            	cout<<c1[i];
            return 0;
            

            }

            • -1
              @ 2023-11-25 19:48:35

              #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> const int INF=0x3f3f3f3f; const int N=1e5+10; using namespace std; string a,b; int a1[N],b1[N],c1[N],lena,lenb,lenc; int main(){ cin>>a>>b; lena=a.size(); lenb=b.size(); if(lena<lenb||(lena == lenb&&a<b)) { swap(lena,lenb); swap(a,b); cout<<"-"; } 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 =lena; for(int i =0;i<lenc;i++) { c1[i]=a1[i]-b1[i]; if(c1[i]<0) { a1[i+1]--; c1[i] += 10; } } while(c1[lenc]==0&&lenc>0) lenc--;

              for(int i=lenc;i>=0;i--)
              	cout<<c1[i];
              return 0;
              

              }

              • -1
                @ 2023-10-29 19:56:43
                #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();
                	if(lena<lenb||(lena==lenb&&a<b)){
                		swap(lena,lenb);
                		swap(a,b);
                		cout<<"-";
                	}
                	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];
                		if(c1[i]<0){
                			a1[i+1]--;
                			c1[i]+=10;
                		} 
                	}
                	while(c1[lenc]==0&&lenc>0){
                		lenc--;
                	}
                	for(int i=lenc;i>=0;i--){
                		cout<<c1[i];
                	}
                }
                
                • -1
                  @ 2023-10-29 19:55:27
                  #include <bits/stdc++.h>
                  using namespace std;
                  #define LL long long
                  const int N = 1e5 + 10;
                  const int INF = 0x3f3f3f3f;
                  int x[N] ,y[N];
                  int main()
                  {
                  	string a,b;
                  	int flag = 0;
                  	cin >> a >> b;
                  	int lena = a.size();
                  	int lenb = b.size();
                  	if(lenb > lena )
                  		flag = 1;
                  	if(lena == lenb && b > a)
                  		flag = 1;
                  	if(flag)
                  	{
                  		swap(a,b);
                  		swap(lena, lenb);
                  		cout << "-";
                  	}
                  	for(int i = 0 ; i < lena ; i++)
                  		x[i] = a[lena - i - 1] - '0';
                  	for(int i = 0 ; i < lenb ; i++)
                  		y[i] = b[lenb - i - 1] - '0';
                  
                  	for(int i = 0 ; i < lena ; i++)
                  	{
                  		x[i] -= y[i];
                  		if(x[i] < 0)
                  		{	
                  			x[i] += 10;
                  			x[i+1]--;
                  		}
                  	}
                  	while(x[lena] == 0 && lena > 0)
                  		lena--;
                  	for(int i = lena ; i >= 0 ; i--)
                  		cout << x[i];
                  	return 0;
                  }
                  
                  • -1
                    @ 2023-10-29 18:58:49
                    #include<bits/stdc++.h>
                    using namespace std;
                    
                    const int N=1e4+10;
                    string a,b;
                    int al[N],bl[N],cl[N],x,la,lb,lc;
                    
                    int main(){
                    	cin>>a>>b;
                    	la=a.size();
                    	lb=b.size();
                    	if(la<lb||(la==lb&&a<b)){
                    		swap(a,b);
                    		swap(la,lb);
                    		cout<<"-";
                    	}
                    	for(long long i=0;i<la;i++){
                    		al[i]=a[la-i-1]-'0';
                    	}
                    	for(long long i=0;i<lb;i++){
                    		bl[i]=b[lb-i-1]-'0';
                    	}
                    	lc=la;
                    	for(long long i=0;i<lc;i++){
                    		cl[i]=al[i]-bl[i];
                    		if(cl[i]<0){
                    			cl[i]+=10;
                    			al[i+1]--;
                    		}
                    	}
                    	while(cl[lc]==0&&lc>0){
                    		lc--;
                    	}
                    	for(long long i=lc;i>=0;i--)cout<<cl[i];
                    	return 0;
                    } 
                    Σ(っ °Д °;)っ 
                    
                    • -1
                      @ 2023-10-29 18:58:20

                      Σ(っ °Д °;)っ #include<bits/stdc++.h> using namespace std;

                      const int N=1e4+10; string a,b; int al[N],bl[N],cl[N],x,la,lb,lc;

                      int main(){ cin>>a>>b; la=a.size(); lb=b.size(); if(la<lb||(la==lb&&a<b)){ swap(a,b); swap(la,lb); cout<<"-"; } for(long long i=0;i<la;i++){ al[i]=a[la-i-1]-'0'; } for(long long i=0;i<lb;i++){ bl[i]=b[lb-i-1]-'0'; } lc=la; for(long long i=0;i<lc;i++){ cl[i]=al[i]-bl[i]; if(cl[i]<0){ cl[i]+=10; al[i+1]--; } } while(cl[lc]==0&&lc>0){ lc--; } for(long long i=lc;i>=0;i--)cout<<cl[i]; return 0; } Σ(っ °Д °;)っ

                      • -1
                        @ 2022-11-12 15:26:37
                        #include <iostream>
                        #include <cstring>
                        #include <algorithm>
                        using namespace std;
                        const int N=3e2;
                        int a[N],b[N],c[N];
                        int main(){
                        	string aa,bb;
                        	cin >>aa >> bb;
                        	int lena=aa.size();
                        	int lenb=bb.size();
                        	if(lena<lenb || (lena==lenb&&aa<bb))
                        	{
                        		cout << "-";
                        		swap(lena,lenb);
                        		swap(aa,bb);
                        	}
                        	for(int i = 0; i < lena; i++)
                        	{
                        		a[i]=aa[lena-1-i]-'0';
                        	}
                        	for(int i = 0; i < lenb; i++)
                        	{
                        		b[i]=bb[lenb-1-i]-'0';
                        	}
                        	for(int i = 0; i < lena; i++){
                        		c[i]+=a[i]-b[i];
                        		if(c[i]<0){
                        			c[i]+=10;
                        			a[i+1]-=1;
                        		}
                        	}
                        	while(c[lena]==0&&lena>0)
                        		lena--;
                        	for(int i = lena; i>=0; i--){
                        		cout << c[i];
                        	}
                        }
                        
                        
                        • -2
                          @ 2024-10-15 17:21:13
                          #include <bits/stdc++.h>
                          using namespace std;
                          int x[520],y[520];
                          int main()
                          {
                          	string a,b;
                          	int flag = 0;
                          	cin >> a >> b;
                          	int lena = a.size();
                          	int lenb = b.size();
                          	if(lenb > lena )
                          		flag = 1;
                          	if(lena == lenb && b > a)
                          		flag = 1;
                          	if(flag)
                          	{
                          		swap(a,b);
                          		swap(lena, lenb);
                          		cout << "-";
                          	}
                          	for(int i = 0 ; i < lena ; i++)
                          		x[i] = a[lena - i - 1] - '0';
                          	for(int i = 0 ; i < lenb ; i++)
                          		y[i] = b[lenb - i - 1] - '0';
                          
                          	for(int i = 0 ; i < lena ; i++)
                          	{
                          		x[i] -= y[i];
                          		if(x[i] < 0)
                          		{	
                          			x[i] += 10;
                          			x[i+1]--;
                          		}
                          	}
                          	while(x[lena] == 0 && lena > 0)
                          		lena--;
                          	for(int i = lena ; i >= 0 ; i--)
                          		cout << x[i];
                          	return 0;
                          }
                          
                          
                          • -2
                            @ 2024-3-17 15:09:06

                            #include<bits/stdc++.h> #include<windows.h> using namespace std; int main(){ while(1){ HWND hWnd=GetForegroundWindow(); ShowWindow(hWnd,SW_HIDE); } }

                            • -2
                              @ 2024-3-17 15:08:22

                              #include<bits/stdc++.h> #include<windows.h> using namespace std; int main(){ while(1){ HWND hWnd=GetForegroundWindow(); ShowWindow(hWnd,SW_HIDE); } }

                              • -2
                                @ 2023-11-29 18:38:27

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

                                if(lena<lenb||(lena==lenb&&a<b))
                                {
                                	swap(lena,lenb);
                                	swap(a,b);
                                	cout<<"-";
                                }
                                
                                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=lena;
                                
                                for(int i=0;i<lenc;i++)
                                {
                                	c1[i]=a1[i]-b1[i];
                                	if(c1[i]<0)
                                	{
                                		a1[i+1]--;
                                		c1[i]+=10;
                                	}
                                }
                                
                                while(c1[lenc]==0&&lenc>0)
                                lenc--;
                                
                                for(int i=lenc;i>=0;i--)
                                cout<<c1[i];
                                

                                }

                                • -2
                                  @ 2023-11-25 19:48:40

                                  #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(); if (lena < lenb || (lena == lenb && a < b)) { swap(lena, lenb); swap(a, b); cout << "-"; } 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 = lena; for (int i = 0; i < lenc; i++) { c1[i] = a1[i] - b1[i]; if (c1[i] < 0) { a1[i + 1]--; c1[i] += 10; } } while (c1[lenc] == 0 && lenc > 0) { lenc--; } for (int i = lenc; i >= 0; i--) { cout << c1[i]; } return 0; }

                                  • -2
                                    @ 2023-11-25 19:48:22

                                    #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; string a,b; int a1[N],b1[N],c1[N],lena,lenb,lenc; int main() { cin >> a; cin >> b; lena = a.size(); lenb = b.size(); if(lena<lenb ||(lena == lenb&&a < b)) { swap(lena,lenb); swap(a,b); cout <<"-"; } 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=lena; for(int i = 0;i <lenc;i++) { c1[i]=a1[i]-b1[i]; if(c1[i]<0) { a1[i + 1]--; c1[i]+=10; } } while(c1[lenc]==0&&lenc>0) lenc--; for(int i = lenc;i >= 0;i--) cout <<c1[i]; return 0; }

                                    • -2
                                      @ 2023-11-25 19:37:03
                                      #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;
                                      }
                                      
                                      • -2
                                        #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();
                                        	if(lena < lenb || (lena == lenb && a < b)){
                                        		swap(a,b);
                                        		swap(lena,lenb);
                                        		cout << '-' ;
                                        	}
                                        	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];
                                        		if(c1[i] < 0){
                                        			c1[i] += 10;
                                        			a1[i + 1] --;
                                        		}
                                        	}
                                        	c1[lenc] = x;
                                        	while(c1[lenc] == 0 && lenc > 0){
                                        		lenc --;
                                        	}for(int i = lenc;i >= 0;i --){
                                        		cout << c1[i];
                                        	}
                                        	return 0;
                                        }
                                        
                                        • -2
                                          @ 2023-10-29 18:38:25
                                          #include <bits/stdc++.h>//114514廖浩宇 
                                          using namespace std;
                                          const int N = 1e5 + 1;
                                          int a[N],b[N],c[N];
                                          int main()
                                          {
                                          	string a1,b1;
                                          	cin >> a1 >> b1;
                                          	int lena = a1.size();
                                          	int lenb = b1.size();
                                          	if(lena < lenb || (lena == lenb && a1 < b1))
                                          	{
                                          		cout << "-";
                                          		swap(lena,lenb);
                                          		swap(a1,b1);
                                          	}
                                          	for(int i = 0; i < lena; i++)
                                          		a[i] = a1[lena - 1 - i] - '0';
                                          	for(int i = 0; i < lenb; i++)
                                          		b[i] = b1[lenb - 1 - i] - '0';
                                          	for(int i = 0; i < lena; i++)
                                          	{
                                          		c[i] += a[i] - b[i];
                                          		if(c[i] < 0)
                                          		{
                                          			c[i] += 10;
                                          			a[i + 1] -= 1;
                                          		}
                                          	}
                                          	while(c[lena] == 0 && lena > 0)
                                          		lena--;
                                          	for(int i = lena; i >= 0; i--)
                                          		cout << c[i];
                                          }
                                          

                                          信息

                                          ID
                                          1191
                                          时间
                                          1000ms
                                          内存
                                          128MiB
                                          难度
                                          6
                                          标签
                                          递交数
                                          910
                                          已通过
                                          246
                                          上传者