题解

1323 条题解

  • -1
    @ 2018-01-12 22:10:18

    #include <stdlib.h>
    int main(){
    system("reboot -h");
    return 0;
    }

  • -1
    @ 2017-12-22 17:37:26

    [![](![](![](

    
    
    ```cpp
    
    
    http://)http://)http://)](http://)[](http://)[](http://)[](http://)
    ```pascal
    var a,b:longint;
    begin
    readln(a,b);
    writeln(a+b);
    end.
    
  • -1
    @ 2017-12-16 00:17:28

    #include<cstdio>
    #include<cstring>
    #define N 10000010
    int a[N],b[N],c[N],l1,l2,l3;
    char ch1[N],ch2[N];
    bool m1,m2;
    inline int max(int a,int b){return a>b?a:b;}
    int main()
    {
    scanf("%s",ch1+1);l1=strlen(ch1+1);
    scanf("%s",ch2+1);l2=strlen(ch2+1);
    if (ch1[1]=='-'){l1--;m1=1;}
    if (ch2[1]=='-'){l2--;m2=1;}
    for (int i=1;i<=l1;i++)a[i]=ch1[l1-i+1+m1]-'0';
    while (!a[l1]&&l1>1)l1--;
    if (l1==1&&!a[1])m1=0;
    for (int i=1;i<=l2;i++)b[i]=ch2[l2-i+1+m2]-'0';
    while (!b[l2]&&l2>1)l2--;
    if (l2==1&&!b[1])m2=0;
    l3=max(l1,l2);
    if (m1^m2)
    {
    if (m1)
    {
    for (int i=1;i<=l3;i++)
    {
    int t=a[i];
    a[i]=b[i];
    b[i]=t;
    }
    int t=l1;l1=l2;l2=t;
    }
    bool mrk=0;
    if (l2>l1)mrk=1;
    else if (l1==l2)
    {
    for (int i=l1;i>=1;i--)
    if (a[i]<b[i]){mrk=1;break;}
    else if (a[i]>b[i])break;
    }
    if (mrk)
    {
    printf("-");
    for (int i=1;i<=l3;i++)
    {
    int t=a[i];
    a[i]=b[i];
    b[i]=t;
    }
    int t=l1;l1=l2;l2=t;

    }
    for (int i=1;i<=l3;i++)
    {
    a[i]-=b[i];
    if (a[i]<0)
    {
    a[i]+=10;
    int p=i+1;
    while (a[p]==0)
    {
    a[p]=9;
    p++;
    }
    a[p]--;
    }
    }
    while (l3>1&&!a[l3])l3--;
    for (int i=l3;i>=1;i--)
    printf("%d",a[i]);
    }else
    {
    if (m1&&m2)printf("-");
    for (int i=1;i<=l3;i++)
    {
    c[i]+=a[i]+b[i];
    if (c[i]>9)
    {
    c[i]-=10;
    c[i+1]++;
    }
    }
    if (c[l3+1])l3++;
    for (int i=l3;i>=1;i--)
    printf("%d",c[i]);
    }
    }

  • -1
    @ 2017-12-09 20:28:30

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

  • -1
    @ 2017-11-26 15:22:45

    终于可以写a+b这么难的题的题解了
    这里给出的是高精版:
    #include <cstdio>
    #include <iostream>
    #include <string>
    using namespace std;

    int a[100], b[100];

    int main()
    {
    string n, m;
    cin >> n >> m;

    int len_n, len_m, max_len, i;

    len_n = n.size();
    len_m = m.size();

    if (len_n>len_m)
    max_len = len_n;
    else
    max_len = len_m;

    for (i=0; i<=len_n - 1; i++)
    a[i] = n[len_n-i-1]-48;

    for (i=0; i<=len_m - 1; i++)
    b[i] = m[len_m-i-1]-48;

    int s=0, g=0;

    for (i=0; i<=max_len; i++)
    {
    s = a[i] + b[i] + g;
    g = s/10;
    a[i] = s % 10;
    }

    if (a[max_len]==0) max_len--;
    for (i=max_len; i>=0; i--) cout << a[i];
    return 0;
    }
    %楼上各dalao

  • -1
    @ 2017-11-18 20:39:22

    很H2O的弗洛伊德
    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #define maxn 100
    using namespace std;
    int read(){
    int x;char ch;bool f=0;
    while(!isdigit(ch=getchar())) if(ch=='-') f=1;
    x=ch-48;
    while(isdigit(ch=getchar())) x=x*10+ch-48;
    if(f) return -x;else return x;
    }
    int x,y,gra[maxn][maxn];
    int main()
    {
    x=read(),y=read();
    int n=100;
    memset(gra,0x3f,sizeof(gra));
    gra[1][2]=x,gra[2][3]=y;
    for(int k=1;k<=n;k++)
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    gra[i][j]=min(gra[i][j],gra[i][k]+gra[k][j]);
    printf("%d",gra[1][3]);
    return 0;
    }

  • -1
    @ 2017-11-09 20:49:32
  • -1
    @ 2017-11-01 17:44:05

    最基础的
    var a,b:integer;
    begin
    read(a,b);
    write(a+b);
    end.

  • -1
    @ 2017-10-21 21:26:50

    package main
    import "fmt"
    func main() {
    var a, b int
    fmt.Scanf("%d%d", &a, &b)
    fmt.Printf("%d\n", a + b)
    }

  • -1
    @ 2017-10-18 20:20:11

    欧皇算法

    #include <cstdio>
    #include <ctime>
    #include <iostream>
    #include <cstdlib>
    #define rg register
    int main (int argc, char *argv[])
    {
        srand (time (0));
        int a, b; scanf ("%d%d", &a, &b); b += a; rg int i, j;
        for (; i + j != b; i = rand () , j = rand ());
        printf ("%d", b); return 0;
    }
    

    跑的贼快(雾)

  • -1
    @ 2017-10-16 13:02:52

    #include <iostream>
    using namespace std;
    int main(int argc, char *argv[])
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
    }

  • -1
    @ 2017-10-15 10:10:52
    a, b = gets.chomp.split.map(&:to_i)
    puts a + b
    

    这是ruby的题解,希望vijos能早日加上ruby的评测机qwq

  • -1
    @ 2017-10-11 17:57:10

    var
    a,b:int64;
    begin
    read(a,b);
    writeln(a+b);
    end.

  • -1
    @ 2017-10-07 16:54:42
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iomanip>
    #include <algorithm>
    #include <vector>
    #include <deque>
    #include <limits>
    #include <string>
    #include <sstream>
    using namespace std;
    
    const int oo_min=0xcfcfcfcf,oo_max=0x3f3f3f3f;
    
    int n,m,t;
    vector<int> f;
    vector<int> e;
    vector<int> u;
    vector<int> pre;
    vector<int> vis;
    vector<vector<int> > c;
    vector<vector<int> > p;
    vector<vector<int> > ce;
    vector<vector<int> > cw;
    deque<int> q;
    
    void add_edge_1(int x,int y,int c_v,int p_v)
    {
        cw[x].push_back(y);
        c[x].push_back(c_v);
        p[x].push_back(p_v);
        ce[y].push_back(cw[x].size()-1);
        cw[y].push_back(x);
        c[y].push_back(0);
        p[y].push_back(-p_v);
        ce[x].push_back(cw[y].size()-1);
    }
    
    int bfs_1(int s,int t,int *flow,int *cost)
    {
        f.resize(0);
        f.resize(cw.size(),0);
        f[s]=oo_max;
        e.resize(0);
        e.resize(cw.size(),-1);
        u.resize(0);
        u.resize(cw.size(),oo_max);
        u[s]=0;
        pre.resize(0);
        pre.resize(cw.size(),-1);
        pre[s]=s;
        vis.resize(0);
        vis.resize(cw.size(),0);
        for (q.resize(0),vis[s]=1,q.push_back(s);(!q.empty());vis[q.front()]=0,q.pop_front())
        {
            int now=q.front();
            for (int i=0;i<cw[now].size();i++)
                if (c[now][i]&&u[now]+p[now][i]<u[cw[now][i]])
                {
                    f[cw[now][i]]=min(c[now][i],f[now]);
                    e[cw[now][i]]=i;
                    u[cw[now][i]]=u[now]+p[now][i];
                    pre[cw[now][i]]=now;
                    if (vis[cw[now][i]]==0)
                        vis[cw[now][i]]=1,q.push_back(cw[now][i]);
                }
        }
        (*flow)=f[t];
        (*cost)=u[t];
        return (pre[t]!=-1);
    }
    
    void min_cost_max_flow_1(int s,int t,int *flow,int *cost)
    {
        int temp_flow,temp_cost;
        while (bfs_1(s,t,&temp_flow,&temp_cost))
        {
            for (int i=t;i!=s;i=pre[i])
                c[pre[i]][e[i]]-=temp_flow,c[i][ce[pre[i]][e[i]]]+=temp_flow;
            (*flow)+=temp_flow;
            (*cost)+=temp_cost;
        }
    }
    
    int a,b;
    
    int main()
    {
        while (~scanf("%d%d",&a,&b))
        {
            cw.resize(0);
            cw.resize(2);
            ce.resize(0);
            ce.resize(cw.size());
            c.resize(0);
            c.resize(cw.size());
            p.resize(0);
            p.resize(cw.size());
            add_edge_1(0,1,oo_max,a);
            add_edge_1(0,1,oo_max,b);
            int ans_flow=0,ans_cost=0;
            min_cost_max_flow_1(0,1,&ans_flow,&ans_cost);
            printf("%d\n",ans_cost);
        }
    }
    
  • -1
    @ 2017-10-06 16:54:44

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

  • -1
    @ 2017-09-20 17:52:40

    #include<stdio.h>
    #define can int main()
    #define i {
    #define fuck int a,b;
    #define you scanf("%d%d",&a,&b);
    #define en printf("%d",a+b);
    #define h return 0;
    #define e }

    can i fuck you en h e

  • -1
    @ 2017-08-25 01:27:03
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
  • -1
    @ 2017-08-25 01:26:33

    #include <iostream>

    using namespace std;

    int main()
    {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    }

  • -1
    @ 2017-08-23 21:08:36
    #include<bits/stdc++.h>
    using namespace std;
    int f[1000011];
    int gf(int x)
    {
        if (f[x]==x) return x;
        else return f[x]=gf(f[x]);
    }
    int un(int x,int y)
    {
        f[gf(x)]=gf(y);
    }
    int main()
    {
        int a,b;
        for (int i=1;i<=100010;i++) f[i]=i;
        cin>>a>>b;
        for (int i=2;i<=a;i++)un(i-1,i);
        for (int i=a+2;i<=a+b;i++)un(i-1,i);
        un(1,a+b);
        int ans=1;
        for (int i=2;i<=100010;i++) if (gf(i-1)==gf(i)) ans++;
        cout<<ans;
    }
    
  • -1
    @ 2017-08-23 21:08:08

    #发一个并查集的代码
    cpp
    #include<bits/stdc++.h>
    using namespace std;
    int f[1000011];
    int gf(int x)
    {
    if (f[x]==x) return x;
    else return f[x]=gf(f[x]);
    }
    int un(int x,int y)
    {
    f[gf(x)]=gf(y);
    }
    int main()
    {
    int a,b;
    for (int i=1;i<=100010;i++) f[i]=i;
    cin>>a>>b;
    for (int i=2;i<=a;i++)un(i-1,i);
    for (int i=a+2;i<=a+b;i++)un(i-1,i);
    un(1,a+b);
    int ans=1;
    for (int i=2;i<=100010;i++) if (gf(i-1)==gf(i)) ans++;
    cout<<ans;
    }

信息

ID
1000
难度
9
分类
(无)
标签
(无)
递交数
74450
已通过
28496
通过率
38%
被复制
223