题解

1323 条题解

  • 0
    @ 2017-08-18 16:56:06

    大家好,这一题其实应该用网络流。
    cpp
    #include<bits/stdc++.h>
    using namespace std;
    #define set(x) Set(x)
    #define REP(i,j,k) for (int i=(j),_end_=(k);i<=_end_;++i)
    #define DREP(i,j,k) for (int i=(j),_start_=(k);i>=_start_;--i)
    #define debug(...) fprintf(stderr,__VA_ARGS__)
    #define mp make_pair
    #define x first
    #define y second
    #define pb push_back
    #define SZ(x) (int((x).size()-1))
    #define ALL(x) ((x).begin()+1),(x).end()
    template<typename T> inline bool chkmin(T &a,const T &b){ return a > b ? a = b, 1 : 0; }
    template<typename T> inline bool chkmax(T &a,const T &b){ return a < b ? a = b, 1 : 0; }
    typedef long long LL;
    typedef pair<int,int> node;
    const int dmax=1010,oo=0x3f3f3f3f;
    int n,m;
    int a[dmax][dmax] , ans;
    int d[dmax],e[dmax];
    priority_queue <node> q;
    inline bool operator >(node a,node b){ return a.y>b.y; }
    bool p[dmax];
    void Set(int x){ p[x]=1; }
    void unset(int x){ p[x]=0; }
    bool check(int x){ return x!=1 && x!=n && !p[x] && e[x]>0; }
    void preflow(){
    e[1]=oo;
    d[1]=n-1;
    q.push(mp(1,n-1));
    set(1);
    while (!q.empty()){
    bool flag=1;
    int k=q.top().x;
    q.pop(),unset(k);
    DREP(i,n,1)
    if ((d[k]==d[i]+1 || k==1) && a[k][i]>0){
    flag=0;
    int t=min(a[k][i],e[k]);
    e[k]-=t;
    a[k][i]-=t;
    e[i]+=t;
    a[i][k]+=t;
    if (check(i)){
    q.push(mp(i,d[i]));
    set(i);
    }
    if (e[k]==0) break;
    }
    if (flag){
    d[k]=oo;
    REP(i,1,n)
    if (a[k][i]>0)
    chkmin(d[k],d[i]+1);
    }
    if (check(k)){
    q.push(mp(k,d[k]));
    set(k);
    }
    }
    ans=e[n];
    }
    int main(){
    n = 2, m = 2;
    int x, y;
    scanf("%d%d", &x, &y);
    a[1][2] += x + y;
    preflow();
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2017-08-16 09:58:08

    C答案,不谢,已AC
    #include <stdio.h>
    int main()
    {
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d",x+y);
    return 0;
    }

  • 0
    @ 2017-08-10 22:03:50

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

  • 0
    @ 2017-08-10 22:03:10

    var n,k,i,num,sum,ans:longint; a:array[0..20] of longint;

    function pangduan(n:longint):integer;
    var xx,i:integer;
    begin
    xx:=trunc(sqrt(n+1));
    for i:=2 to xx do
    if (n mod i=0) then exit(0);
    exit(1);
    end;

    procedure doit(t:longint);
    var p,i:longint;
    begin
    if (num=k) then
    begin
    p:=pangduan(sum);
    if (p=1) then inc(ans);
    exit;
    end;
    for i:=t+1 to n do
    begin
    inc(num);
    sum:=sum+a[i];
    doit(i);
    sum:=sum-a[i];
    dec(num);
    end;
    end;

    begin
    readln(n,k);
    for i:=1 to n do read(a[i]);
    for i:=1 to n-k+1 do
    begin
    num:=1;
    sum:=a[i];
    doit(i);
    end;
    writeln(ans);
    end.

  • 0
    @ 2017-08-10 19:11:40

    冷清啊。。我来一发Python3的题解

    a, b = map(int, input().split())
    print(a + b)
    

    恩 就是这么简洁qwq

  • 0
    @ 2017-08-05 11:40:48
    #include <iostream>
    using namespace std;
    int main()
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
        return 0;
    }
    
  • 0
    @ 2017-08-05 11:40:27

    #include <iostream>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • 0
    @ 2017-07-13 15:52:01

    #include<iostream>
    using namespace std;
    int main()
    {
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    cout<<c<<endl;
    return 0;
    }

  • 0
    @ 2017-07-12 15:01:01

    很简单

    #include <cstdio>
    #include <iostream>
    using namespace std;
    int main() {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
        return 0;
    }
    
  • 0
    @ 2017-07-09 11:46:18

    #include<iostream>
    #include<cstdio>
    #include<ctime>
    #include<algorithm>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    using namespace std;
    int main()
    {
    int A,B;
    cin>>A>>B;
    cout<<A+B;
    return 0;
    }

  • 0
    @ 2017-07-07 20:15:45
    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    using namespace std;
    const int mx = 500000 + 100;
    struct node{
        int l,r;
        long long lazy,sum;
    }tree[mx * 4];
    int a[mx];
    /*
        Segment-Tree Gerneral Tools
        **--Using Marco--**
        Marco l(seq)
            Get left Sequence Number
        Marco r(seq)
            Get Right Sequence Number
        Marco lt(seq)
            Get Left Tree
        Marco pt(seq)
            Get Present Tree
        Marco trlen(seq)
            Get Tree Length
        Marco trmid(seq)
            Get Middle Sequence Number
    */
    #define l(seq)  seq * 2
    #define r(seq)  l(seq) + 1
    #define lt(seq) tree[l(seq)]
    #define rt(seq) tree[r(seq)]
    #define pt(seq) tree[seq]
    #define trlen(seq)  (pt(seq).r - pt(seq).l + 1)
    #define trmid(seq)  (pt(seq).r + pt(seq).l)/2
    
    void PushUp(int seq){
        pt(seq).sum = lt(seq).sum + rt(seq).sum;
    }
    void PushDown(int seq){
        if (pt(seq).lazy){
            int lz = pt(seq).lazy;
            rt(seq).lazy += lz;
            lt(seq).lazy += lz;
            rt(seq).sum += lz * trlen(r(seq));
            lt(seq).sum += lz * trlen(l(seq));
            pt(seq).lazy = 0;
        }
    }
    void Build(int l,int r,int seq){
        pt(seq).l = l;
        pt(seq).r = r;
        if (l == r){
            pt(seq).sum = a[l];
            return;
        }
        int mid = (l + r)/2;
        Build(l,mid,l(seq));
        Build(mid + 1,r,r(seq));
        PushUp(seq);
    }
    void Update(int a,int b,int alt,int seq){
        int l = pt(seq).l,
            r = pt(seq).r;
        if (l == a && b == r){
            pt(seq).lazy += alt;
            pt(seq).sum += alt * trlen(seq);
            return;
        }
        PushDown(seq);
        int mid = trmid(seq);
        if (b <= mid)
            Update(a,b,alt,l(seq));
        else if (a > mid)
            Update(a,b,alt,r(seq));
        else{
            Update(a,mid,alt,l(seq));
            Update(mid + 1,b,alt,r(seq));
        }
        PushUp(seq);
    }
    long long Query(int a,int b,int seq){
        int l = pt(seq).l,
            r = pt(seq).r;  
        if (l == a && b == r){
            return pt(seq).sum;
        }
        PushDown(seq);
        int mid = trmid(seq);
        if (b <= mid){
            return Query(a,b,l(seq));
        }
        if (a > mid)
            return Query(a,b,r(seq));
        return Query(a,mid,l(seq)) + Query(mid + 1,b,r(seq));
    }
    int main(){
        for (int i = 1;i <= 2;i++)
            scanf("%d",&a[i]);
        Build(1,2,1);
        printf("%d\n",Query(1,2,1));
        return 0;
    }
    
  • 0
    @ 2017-07-06 17:44:12
    #include <bits/stdc++.h>
    using namespace std;
    
    int a, b;
    
    int main (int argc, char* argv[]) {
          cin >> a >> b;
            cout << a+b << endl;
            return 0;'
        }
    
  • 0
    @ 2017-07-06 10:53:59

    //读入优化
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int read()
    {
    int x=0;char c;int f=1;
    for(c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+c-'0';
    return x*f;
    }
    int a,b;

    int main()
    {
    a=read();
    b=read();
    cout<<a+b<<endl;
    }

  • 0
    @ 2017-07-01 18:48:19

    #include <stdio.h>
    int main()
    {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",a+b);
    }

  • 0
    @ 2017-06-29 09:06:36

    一道最基本的入门题,是基础,很简单
    #include<cstdio>
    #include<iostream>
    using namespace std;
    int main()
    {
    int n,m,k;
    cin>>n>>m;
    k=n+m;
    cout<<k;
    return 0;
    }

  • 0
    @ 2017-06-22 20:26:39

    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • 0
    @ 2017-06-22 20:25:44

    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • 0
    @ 2017-06-22 20:25:12

    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • 0
    @ 2017-05-29 19:06:27
    #include<iostream>
    using namespace std;
    
    int main()
    {
        int a,b;
            cin>>a>>b;
            cout<<a+b;
            return 0;
    }
    
  • 0
    @ 2016-12-14 13:14:54

    好长时间才做出来
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    char a1[10000],b1[10000];int a[10000],b[10000],c[10000],x=0,lena,lenb,lenc=1,i;
    int main()
    {
    scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1);
    for(i=0;i<=lena-1;i++) a[lena-i]=a1[i]-'0';
    for(i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-'0';
    while(lenc<=lena||lenc<=lenb)
    {
    c[lenc]=a[lenc]+b[lenc]+x;
    x=c[lenc]/10;
    c[lenc]%=10;
    lenc++;
    }
    if(0==(c[lenc]=x)) lenc--;
    for(i=lenc;i>=1;i--) cout<<c[i];return 0;
    }

信息

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