4 条题解

  • 0
    @ 2023-12-9 22:24:17

    高精度算法:

    #include <iostream>
    #include <iomanip>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define sn setprecision
    const int N =1e5+10;
    const int INF =0x3f3f3f3f;
    const double pei=3.14;
    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-12-9 22:17:52

      自定义函数:

      #include <iostream>
      #include <iomanip>
      #include <cstdio>
      #include <cstring>
      #include <algorithm>
      using namespace std;
      #define ll long long
      #define ull unsigned long long
      #define sn setprecision
      const int N =1e5+10;
      const int INF =0x3f3f3f3f;
      const double pei=3.14;
      int a,b;
      int aplusb(int x,int y)
      {
      	cout<<x+y;
      	return 1;
      }
      int main()
      {
      	cin>>a>>b;
      	aplusb(a,b);	
       	return 0;
      }
      
      • 0
        @ 2023-10-8 22:41:14
        #include <iostream>
        #include <stdio.h>
        using namespace std;
        int a,b;
        int main()
        {
        	cin>>a>>b;
        	int c=a;
        	int d=b;
        	int z=d;
        	int x=c;
        	if(a<=b)
        	{
        		int sum=c+a;
        		cout<<(sum-a)+(b+c-a)<<endl;
        	}
        	if(0>=a&&0>=b)
        	{
        		int num=a+b;
        		cout<<(num-a)+(b+c-a)<<endl;	
        	}
        	else if(a>b)
        	{
        		if(a!=0&&b!=0&&a+b!=0&&a+b>=0&&a*0+b*0==0&&a>=0&&b>=0)
        		{
        			int bag=a+b;
        			int apple=bag;
        			cout<<apple;
        		}
        		int num=a+b;
        		cout<<(num-a)+(b+c-a)<<endl;
        	}
        	return 0;
        }
        
        • 0
          @ 2023-1-19 21:40:14

          就是普通的A+B

          hack好像有点bug

          要开long long 哦

          ACCODE

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

          信息

          ID
          21
          时间
          1000ms
          内存
          256MiB
          难度
          1
          标签
          递交数
          239
          已通过
          39
          上传者