6 条题解

  • 1
    @ 2023-11-17 22:38:55
    #include<bits/stdc++.h>
    using namespace std;
    const int N=100001;
    int a[N],b[N],ml;
    void add(int a[],int b[])
    {
        int cnt=0;
        for(int i=1;i<=ml+1;i++)
        {
            cnt+=a[i]+b[i];
            a[i]=cnt%10;
            cnt/=10;
        }
        return;
    }
    void print(int a[])
    {
        int i;
        for(i=ml+1;i>0&&!a[i];i--);
        if(!i)
        {
            cout<<0;
            return;
        }
        while(i)
        {
            cout<<a[i--];
        }
    }
    int main()
    {
        string sa,sb;
        cin>>sa>>sb;
        int la=sa.size(),lb=sb.size();
        ml=la>lb?la:lb;
        for(int i=1;i<=la;i++)
        {
            a[i]=sa[la-i]-'0';
        }
        for(int i=1;i<=lb;i++)
        {
            b[i]=sb[lb-i]-'0';
        }
        add(a,b);
        print(a);
        return 0;
    }
    
  • 1

    def (,__):
    ____ = +_
    return ____
    __ = int(input())
    ___ = int(input())
    ____ = (,)
    print(
    __)

  • 1
    @ 2018-10-22 22:46:52

    dijkstra+堆优化

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cctype>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<map>
    #define INF 2147483647
    #define LL long long
    #define ULL unsigned long long
    #define MAXN 10005
    using namespace std;
    inline int read()
    {
        char ch=getchar();
        int x=0,f=1;
        while(!isdigit(ch))
        {
            if(ch=='-') f=-1;
            ch=getchar();
        }
        while(isdigit(ch))
        {
            x=x*10+ch-'0';
            ch=getchar();
        }
        return x*f;
    }
    struct Edge{
        int v,w;
        Edge(int v=0,int w=0):v(v),w(w){}
        
    };
    struct Node{
        int id;
        LL d;
        Node(int id=0,LL d=0):id(id),d(d){}
        bool operator <(const Node& n1)const{
            return d>n1.d;
        }
    };
    vector<Edge> adj[500005];
    priority_queue<Node> q;
    int n,m,s;
    LL d[MAXN];
    bool vis[MAXN];
    void dijkstra(int st)
    {
        for(int i=1;i<=n;i++) d[i]=INF;
        d[st]=0;
        int u=0,v=0,w=0;
        q.push(Node(st,0));
        while(!q.empty())
        {
            u=q.top().id;
            q.pop();
            if(vis[u]) continue;
            vis[u]=1;   
            int len=adj[u].size();
            for(int i=0;i<len;i++)
            {
                v=adj[u][i].v;
                w=adj[u][i].w;
                if(d[u]+w<d[v])
                {
                    d[v]=d[u]+w;
                    q.push(Node(v,d[v]));
                }
            }
        }
    }
    int aa,bb;
    int main()
    {
        aa=read();
        bb=read();
        n=3;
        adj[1].push_back(Edge(2,aa));
        adj[2].push_back(Edge(3,bb));
        dijkstra(1);
        printf("%lld",d[3]);
        return 0;
    }
    
    
  • 0
    @ 2020-09-16 22:55:37

    #python3

    a=int(input())
    b=int(input())
    print(a+b)
    
  • -2
    @ 2019-01-14 16:23:47

    print(int(input())+int(input()))

  • -2
    @ 2018-10-24 13:02:51
    string a1,b1;
    bigN a,b;
    int main()
    {
        cin>>a1>>b1; 
        bigN a(a1),b(b1);
        cout<<a+b; 
        return 0;
    }
    

    这样就行了

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    什么?CE了?
    ```cpp
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cctype>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<map>
    #define INF 1<<30
    #define LL long long
    #define ULL unsigned long long
    #define MAXN 50005
    using namespace std;

    struct bigN{
    int num[MAXN];
    int len;
    bigN(const string& s1)
    {
    len=s1.length();
    for(int i=0,p=len-1;p>=0;i++,p--)
    {
    num[i]=s1[p]-'0';
    }
    }
    bigN()
    {
    len=0;
    memset(num,0,sizeof(num));
    }
    bigN operator +(const bigN& n1){
    bigN n3;
    n3.len=max(len,n1.len);
    for(int i=0;i<n3.len;i++)
    {
    n3.num[i]+=n1.num[i]+num[i];
    n3.num[i+1]+=n3.num[i]/10;
    n3.num[i]%=10;
    }
    if(n3.num[n3.len]!=0) n3.len++;
    return n3;
    }
    };
    ostream& operator <<(ostream& os,const bigN& n1){
    for(int i=n1.len-1;i>=0;i--)
    os<<n1.num[i];
    return os;
    }
    string a1,b1;
    bigN a,b;
    int main()
    {
    cin>>a1>>b1;
    bigN a(a1),b(b1);
    cout<<a+b;
    return 0;
    }

  • 1

信息

难度
1
分类
(无)
标签
(无)
递交数
5272
已通过
1242
通过率
24%
被复制
1
上传者