题解

1323 条题解

  • -1
    @ 2019-03-25 19:49:38

    大家都太不正常了
    我个小蒟蒻瑟瑟发抖
    代码也瑟瑟发抖

    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #include<cstdlib>
    #include<cstdio>
    #include<cstring>
    #include<queue>
    #define ll long long
    #define in read();
    using namespace std;
    namespace FastIO{
        const ll L=1<<15;
        char buffer[L],*S,*T;
        inline char getchar(){
            if(S==T){T=(S=buffer)+fread(buffer,1,L,stdin);if(S==T)return EOF;}
            return *S++;
        }
        inline ll read(){
            char c=getchar();ll rec=0,f=1;
            while(!isdigit(c)) {if(c=='-')f=-1;c=getchar();}
            while(isdigit(c))rec=(rec<<1)+(rec<<3)+(c^'0'),c=getchar();
            return rec*f;
        }
    }using FastIO::read;
    const ll N=110000;
    ll first[N],size=0;
    struct date{ll to,next,len;}bian[N<<1];
    void add(ll x,ll y,ll z){
        size++;
        bian[size].next=first[x];
        first[x]=size;
        bian[size].to=y;
        bian[size].len=z;
    }
    ll n,m,Q;
    ll a,b,c;  //long long !!!!
    ll dis[N],dep[N],fa[N][21];
    ll lca(ll x,ll y)
    {
        if(dep[x]<dep[y]) swap(x,y);
        ll t=dep[x]-dep[y];
        for(ll i=0;i<20;i++)
            if((1<<i)&t) x=fa[x][i];
        if(x==y) return x;
        ll j=19;
        while(fa[x][0]!=fa[y][0])
        {
            if(fa[x][j]!=fa[y][j]) x=fa[x][j],y=fa[y][j];
            j--;
        }
        return fa[x][0];
    }
    ll ST[N][20],dfs_clock=0,pos[N];
    ll DD(ll x,ll y)
    {
        ll l=pos[x],r=pos[y];
        if(l>r)swap(l,r);
        ll L=floor(log2(r-l+1));
        return min(ST[l][L],ST[r-(1<<L)+1][L]);
    }
    ll dist(ll x,ll y)
    {
        return dis[x]+dis[y]-2*DD(x,y);
    }
    void dfs(ll u,ll lst)
    {
        ST[++dfs_clock][0]=dis[u]; pos[u]=dfs_clock;
        for(ll i=first[u];i;i=bian[i].next)
        {
            ll to=bian[i].to;
            if(to==lst) continue;
            dep[to]=dep[u]+1;
            dis[to]=dis[u]+bian[i].len;
            fa[to][0]=u;
            dfs(to,u);
            ST[++dfs_clock][0]=dis[u];
        }
    }
    void S_T()
    {
        for(ll j=1;j<20;j++)
            for(ll i=1;i<=n;i++)
                fa[i][j]=fa[fa[i][j-1]][j-1];
        for(ll j=1;j<19;j++)
            for(ll i=1;i+(1<<j)<=n;i++)
                ST[i][j]=min(ST[i][j-1],ST[i+(1<<(j-1))][j-1]);
    }
    ll vis[N],d[N];
    ll getpos(ll s)
    {
        queue<ll>q;
        memset(vis,0,sizeof(vis));
        memset(d,0,sizeof(dis));
        q.push(s); ll Max=0,p;
        while(!q.empty())
        {
            ll u=q.front();q.pop();
            if(vis[u]) continue; vis[u]=1;
            if(d[u]>Max) p=u,Max=d[u];
            for(ll i=first[u];i;i=bian[i].next)
            {
                ll to=bian[i].to; if(vis[to]) continue;
                d[to]=d[u]+bian[i].len;
                q.push(to);
            }
        }
        return p;
    }
    ll core[N],s[N],D[N][21];
    ll up_find(ll x,ll top,ll q)
    {
        if(s[x]>=q) return x;
        if(x==top) return -1;
        ll Max=0;
        for(ll j=19;j>=0;j--)
            if(fa[x][j] && D[x][j]<q && dep[fa[x][j]]>=dep[top]) x=fa[x][j];
        if(s[x]>=q) return x;
        if(x!=top && s[fa[x][0]]>=q) return fa[x][0];
        return -1;
    }
    ll the_max(ll x,ll to)
    {
        if(x==to) return s[x];
        if(dep[to]>dep[x]) swap(x,to);
        ll t=dep[x]-dep[to];
        ll Max=s[x];
        for(ll j=19;j>=0;j--)
            if(fa[x][j] && dep[fa[x][j]]>=dep[to]) Max=max(Max,D[x][j]),x=fa[x][j];
        return Max;
    }
    ll down_find(ll x,ll top,ll q)
    {
        if(x==top) 
        {
            if(s[x]>=q) return x;
            return -1; 
        }
        ll t=dep[x]-dep[top];
        ll l=0,r=t,ans=-1,mid,temp=x;
        while(l<=r)
        {
            mid=l+r>>1;
            //cout<<mid<<endl;
            temp=x;
            for(ll j=0;j<19;j++)
                if(mid&(1<<j)) temp=fa[temp][j];
    //      cout<<temp<<' '<<top<<' '<<the_max(temp,top)<<endl;
            if(the_max(temp,top) >= q) ans=temp,l=mid+1;
            else r=mid-1; 
        }
        return ans;
    }
    ll query(ll x,ll y,ll q)
    {
        ll top=lca(x,y);
        //cout<<top<<endl;
        if(top==x)
        {
            //cout<<"???????";
            return down_find(y,top,q);
            //
        }
        ll t=up_find(x,top,q);
        if(t!=-1) return t;
        t=down_find(y,top,q);
        return t;
    }
    int main()
    {
    //  freopen("test.in","r",stdin);
    //  freopen("shelter.out","w",stdout);
        n=in; Q=in; a=in; b=in; c=in;
        for(ll i=1,x,y,z;i<n;i++)
        {
            x=in;y=in;z=in;
            add(x,y,z);add(y,x,z);
        }
        dfs(1,0); S_T();
                
        ll s1=getpos(1);
        ll s2=getpos(s1);
        ll L=dist(s1,s2);
        
        ll tot=0;
        for(ll i=1;i<=n;i++)
            if(dist(s1,i)==L || dist(s2,i)==L) core[++tot]=i;
        
        memset(d,0,sizeof(d));
        for(ll i=1;i<=n;i++)
        {
            for(ll j=1;j<=tot;j++)
                d[i]=max(d[i],dist(i,core[j])); //??????????
            s[i]=1ll*(d[i]+a) * b % c;
        }
    
    
        for(ll i=1;i<=n;i++) D[i][0]=s[fa[i][0]];
        for(ll j=1;j<19;j++)
            for(ll i=1;i<=n;i++)
                D[i][j]=max(D[i][j-1],D[fa[i][j-1]][j-1]);
        ll x,y,z;
    //  for(ll i=1;i<=n;i++) cout<<s[i]<<' ';cout<<endl;
    //  cout<<the_max(5,1)<<endl;
        while(Q--)
        {
            x=in; y=in; z=in;
            printf("%lld\n",query(x,y,z));
        }
        return 0;
    }
    
    • @ 2019-03-25 19:58:53
      #include<cstdio>
      int main(){
              int a,b;
              scanf("%d%d",&a,&b);
              printf("%d",a+b);
              return 0;
      }
      
      
  • -1
    @ 2019-03-05 15:59:51

    cin >> a >> b;
    cout << a + b << endl; 即可。这样输出的是 \(a + b\)

  • -1
    @ 2019-02-12 15:14:54
    #include<bits/stdc++.h>
    using namespace std;
    
    int a;int b;
    
    void write(int x){
        if(x==0){putchar(48);return;}
        int len=0,dg[20];
        while(x>0){dg[++len]=x%10;x/=10;}
        for(int i=len;i>=1;i--)putchar(dg[i]+48);
    }
    
    inline bool read(int &num)  
    {
            char in;bool IsN=false;
            in=getchar();
            if(in==EOF) return false;
            while(in!='-'&&(in<'0'||in>'9')) in=getchar();
            if(in=='-'){ IsN=true;num=0;}
            else num=in-'0';
            while(in=getchar(),in>='0'&&in<='9'){
                    num*=10,num+=in-'0';
            }
            if(IsN) num=-num;
            return true;
    }
    
    int main()
    {
        read(a);
        read(b);
        write(a+b);
        return 0;
    }
    

    已经很快了吧qaq
    快读加快输(毒瘤

  • -1
    @ 2018-12-22 15:44:55

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

  • -1
    @ 2018-11-13 22:17:24

    看到题解并不水,发现自己想简单了,应该是数据水

  • -1
    @ 2018-11-09 21:58:08

    天生爱恶搞
    咋地?咬我?
    啦啦啦啦啦啦啦啦啦啦啦啦……#@\(#^%\)@@!
    好,开始我们的代码
    Dijkstra+STL优先队列优化。
    ```cpp
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <climits>
    #include <algorithm>
    #include <map>
    #include <queue>
    #include <vector>
    #include <ctime>
    #include <string>
    #include <cstring>
    using namespace std;
    const int N=405;
    struct Edge {
    int v,w;
    };
    vector<Edge> edge[N*N];
    int n;
    int dis[N*N];
    bool vis[N*N];
    struct cmp {
    bool operator()(int a,int b) {
    return dis[a]>dis[b];
    }
    };
    int Dijkstra(int start,int end)
    {
    priority_queue<int,vector<int>,cmp> dijQue;
    memset(dis,-1,sizeof(dis));
    memset(vis,0,sizeof(vis));
    dijQue.push(start);
    dis[start]=0;
    while(!dijQue.empty()) {
    int u=dijQue.top();
    dijQue.pop();
    vis[u]=0;
    if(u==end)
    break;
    for(int i=0; i<edge[u].size(); i++) {
    int v=edge[u][i].v;
    if(dis[v]==-1 || dis[v]>dis[u]+edge[u][i].w) {
    dis[v]=dis[u]+edge[u][i].w;
    if(!vis[v]) {
    vis[v]=true;
    dijQue.push(v);
    }
    }
    }
    }
    return dis[end];
    }
    int main()
    {
    int a,b;
    scanf("%d%d",&a,&b);
    Edge Qpush;

    Qpush.v=1;
    Qpush.w=a;
    edge[0].push_back(Qpush);

    Qpush.v=2;
    Qpush.w=b;
    edge[1].push_back(Qpush);

    printf("%d",Dijkstra(0,2));
    return 0;
    }
    ```

  • -1
    @ 2018-11-07 14:29:03

    #include <iostream>

    using namespace std;

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

    典型c++算法,大爱noip!

  • -1
    @ 2018-11-03 14:49:16

    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    #include<cstdlib>
    using namespace std;
    long long l,s,t,m;
    long long map[1000005];
    long long k[1000005];
    long long pos[105];
    long long ans[1000005];
    long long min(long long x,long long y)
    {
    if(x<y)return x;
    return y;
    }
    int main()
    {
    for(int i=0;i<=1000004;i++)
    ans[i]=99999999;
    scanf("%I64d%I64d%I64d%I64d",&l,&s,&t,&m);
    long long mod=s*t;
    for(int i=1;i<=m;i++)
    scanf("%I64d",&pos[i]);
    sort(pos+1,pos+m+1);
    int temp=0;
    for(int i=1;i<=m;i++)
    {
    long long cha=pos[i]-pos[i-1];
    long long qwe=cha;
    cha%=mod; qwe/=mod;
    temp+=cha;
    if(qwe!=0)
    temp+=mod;
    k[temp]=1;
    }
    temp+=s*t;
    if(s==t)
    {
    long long u=0;long long v=s;int an=0;
    while(u<=temp)
    {
    u+=v;
    if(k[u])an++;
    }
    printf("%d",an);
    exit(0);
    }
    for(int i=0;i<=s-1;i++)
    ans[i]=0;
    for(int i=s;i<=temp;i++)
    {
    for(int j=s;j<=t;j++)
    {
    if(i-j<0)break;
    if(i-j>0&&i-j<s)continue;
    ans[i]=min(ans[i-j]+k[i],ans[i]);
    }
    }
    printf("%I64d",ans[temp]);
    }

  • -1
    @ 2018-10-19 19:13:41

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

  • -1
    @ 2018-09-30 18:31:30

    重载运算符
    #include<iostream>
    using namespace std;
    struct p1000
    {
    int num;
    int operator +(p1000 x)
    {return x.num+num;}
    }a,b;
    int main()
    {
    cin>>a.num>>b.num;
    cout<<a+b;
    return 0;
    }

  • -1
    @ 2018-08-25 19:38:21

    C++算法
    1. #include<iostream>
    2. using namespace std;
    3. int main(){
    4. int x,y;
    5. cin>>x>>y;
    6. return 0;
    5. }

  • -1
    @ 2018-08-22 11:25:19

    最标准的C:

    #include<iostream>
    #inckude<cstdio>
    using namespace std;
    int main()
    {
      int a,b,c;
      cin>>a>>b;
      c=a+b;
      std::cout<<c;
      return 0;   
    }
    
  • -1
    @ 2018-08-22 11:24:10

    最标准的c++入门写法(太蒟蒻):

    上*code*:

    #include<iostream>
    #inckude<cstdio>
    using namespace std;
    int main()
    {
      int a,b,c;
      cin>>a>>b;
      c=a+b;
      std::cout<<c;
      return 0;   
    }
    
  • -1
    @ 2018-08-16 21:00:58

    <div>
    <!DOCTYPE html>
    <head>
    <meta charset="utf-8">
    <title>我好菜啊</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
    #scene{
    position: relative;
    width: 400px;
    height: 400px;
    background-color: #000;
    color:#fff;
    text-align: center;
    font-weight: 700;
    font-size: 72px;
    }
    #scene div.layer{
    width:400px;
    height: 100px;
    position: absolute;
    margin:auto;
    left:0;
    right:0;
    top:0;
    bottom:0;
    }
    .blueFlash{
    color: rgb(1, 205, 232);
    -webkit-animation: blueFlash .9s infinite both;
    }

    .pinkFlash{
    color: rgb(255, 37, 233);
    -webkit-animation: pinkFlash .9s infinite both;
    }

    @-webkit-keyframes pinkFlash{
    0%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 0, 0);
    }
    62.5%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 2, 2);
    }
    75%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 3, 3);
    }
    87.5%{
    opacity:1;
    transform: matrix(1, 0, 0, 1, 4, 4);
    }
    100%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 0, 0);
    }

    }
    @-webkit-keyframes blueFlash{
    0%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 0, 0);
    }
    12.5%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 2, 2);
    }
    25%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 3, 3);
    }
    37.5%{
    opacity:1;
    transform: matrix(1, 0, 0, 1, 4, 4);
    }
    50%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, -1, -1);
    }
    62.5%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, -2, -2);
    }
    75%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, -3, -3);
    }
    87.5%{
    opacity:1;
    transform: matrix(1, 0, 0, 1, -4, -4);
    }
    100%{
    opacity:0;
    transform: matrix(1, 0, 0, 1, 0, 0);
    }
    }

    </style>
    </head>
    <body>
    <div id="scene">
    <div class="layer">
    <div class="text_holder pinkFlash">我好菜啊</div>
    </div>
    <div class="layer">
    <div class="text_holder blueFlash">我好菜啊</div>
    </div>
    <div class="layer">
    <div class="text_holder">我好菜啊</div>
    </div>
    </div>
    </body>
    </div>

  • -1
    @ 2018-03-18 20:20:04

    不要给蒟蒻们留下不好的印象,是时候来一波真正的技术了!

    #include<iostream>
    #include<cstdio>
    using namespace std ;
    //Vijos P1000
    
    int x , y ;
    int main()
    {
        scanf("%d%d" , &x , &y) ;
        printf("%d" , x + y) ;
        return 0 ;
    }
    
  • -1
    @ 2018-02-28 15:46:31

    #include<bits/stdc++.h>//万能头文件
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • -1
    @ 2018-02-23 11:58:21

    这里献上最短代码
    #include <bits/stdc++.h>
    int main(int a,int b)
    { return (scanf("%d%d",&a,&b),printf("%d\n",a+b))&0; }

  • -1
    @ 2018-02-11 00:20:01

    #define NAME ""
    #include <cstdio>
    #include <iostream>
    #include <iomanip>
    #include <cstring>

    using namespace std;

    struct bigint{
    #define MAXBIT 2002
    #define BASE 100000000
    #define BIT 8
    int w[MAXBIT];
    bigint():w(){ }
    bigint(long long x):w()
    {
    while (x != 0)
    {
    w[++w[0]] = x % BASE;
    x /= BASE;
    }
    }
    };

    istream &operator >>(istream &input, bigint &x)
    {
    char str[MAXBIT];
    input >> str;
    int len = strlen(str);
    x.w[0] = ((len % BIT == 0) ? 0 : 1) + len / BIT;
    for (int i = 1; i <= x.w[0]; ++i)
    {
    int t = len - i * BIT;
    int base = BASE / 10;
    for (int j = 0; j < BIT; ++j)
    {
    if (str[t + j] == 0)
    str[t + j] = '0';
    x.w[i] += (str[t + j] - '0') * base;
    base /= 10;
    }
    }
    return input;
    }

    ostream &operator <<(ostream &output, const bigint &x)
    {
    output << x.w[x.w[0]];
    for(int i = x.w[0] - 1; i >= 1; --i)
    output << setfill('0') << setw(BIT) << x.w[i];
    return output;
    }

    bigint operator + (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = max (a.w[0], b.w[0]) + 1;
    for (int i = 1; i < c.w[0]; ++i)
    {
    c.w[i] += a.w[i] + b.w[i];
    c.w[i + 1] += c.w[i]/BASE;
    c.w[i] %= BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator * (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = a.w[0] + b.w[0];
    for (int i = 1; i <= a.w[0]; ++i)
    {
    for (int j = 1; j <= b.w[0]; ++j)
    {
    unsigned long long t = c.w[i + j - 1] + (unsigned long long) a.w[i] * (unsigned long long) b.w[j];
    c.w[i + j] += t/BASE;
    c.w[i + j - 1] = t%BASE;
    }
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator - (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0]= a.w[0]+1;
    for(int i =1; i< c.w[0]; ++i)
    {
    int o=0;
    if(a.w[i]<b.w[i]){
    c.w[i+1]--;
    o=1;
    }
    c.w[i]+=a.w[i]-b.w[i]+o*BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    int convert(const bigint &a)
    {
    int ret = 0, power = 1;
    for (int i = 1; i <= a.w[0]; ++i, power *= BASE)
    ret += a.w[i] * power;
    return ret;
    }

    bool operator < (const bigint &a, const bigint &b)
    {
    if (a.w[0] != b.w[0])
    return a.w[0] < b.w[0];
    else
    for(int i = a.w[0]; i >= 1; --i)
    if (a.w[i] != b.w[i])
    return a.w[i] < b.w[i];
    return false;
    }

    bool operator > (const bigint &a, const bigint &b)
    {
    return b < a;
    }

    bool operator == (const bigint &a, const bigint &b)
    {
    return (!(a < b)) && (!(b < a));
    }

    bool operator <= (const bigint &a, const bigint &b)
    {
    return !(b < a);
    }

    bool operator >= (const bigint &a, const bigint &b)
    {
    return !(a < b);
    }

    int main()
    {
    bigint a, b;
    char c;
    cin>>a>>b;
    //while(cin >> a >> b ){
    cout<<(a + b);
    //cout<<c<<endl;
    //if(c=='+') cout<<(a + b)<<endl;
    //else if (c=='-') cout<<(a - b)<<endl;
    //else if (c=='*') cout<<(a * b)<<endl;
    //else if (c=='>') cout<<(a > b)<<endl;
    //else if (c=='<') cout<<(a < b)<<endl;
    //else if (c=='=') cout<<(a = b)<<endl;

    //}
    return 0;
    }
    这才是正解

  • -1
    @ 2018-02-11 00:19:39

    **#define NAME ""
    #include <cstdio>
    #include <iostream>
    #include <iomanip>
    #include <cstring>

    using namespace std;

    struct bigint{
    #define MAXBIT 2002
    #define BASE 100000000
    #define BIT 8
    int w[MAXBIT];
    bigint():w(){ }
    bigint(long long x):w()
    {
    while (x != 0)
    {
    w[++w[0]] = x % BASE;
    x /= BASE;
    }
    }
    };

    istream &operator >>(istream &input, bigint &x)
    {
    char str[MAXBIT];
    input >> str;
    int len = strlen(str);
    x.w[0] = ((len % BIT == 0) ? 0 : 1) + len / BIT;
    for (int i = 1; i <= x.w[0]; ++i)
    {
    int t = len - i * BIT;
    int base = BASE / 10;
    for (int j = 0; j < BIT; ++j)
    {
    if (str[t + j] == 0)
    str[t + j] = '0';
    x.w[i] += (str[t + j] - '0') * base;
    base /= 10;
    }
    }
    return input;
    }

    ostream &operator <<(ostream &output, const bigint &x)
    {
    output << x.w[x.w[0]];
    for(int i = x.w[0] - 1; i >= 1; --i)
    output << setfill('0') << setw(BIT) << x.w[i];
    return output;
    }

    bigint operator + (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = max (a.w[0], b.w[0]) + 1;
    for (int i = 1; i < c.w[0]; ++i)
    {
    c.w[i] += a.w[i] + b.w[i];
    c.w[i + 1] += c.w[i]/BASE;
    c.w[i] %= BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator * (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0] = a.w[0] + b.w[0];
    for (int i = 1; i <= a.w[0]; ++i)
    {
    for (int j = 1; j <= b.w[0]; ++j)
    {
    unsigned long long t = c.w[i + j - 1] + (unsigned long long) a.w[i] * (unsigned long long) b.w[j];
    c.w[i + j] += t/BASE;
    c.w[i + j - 1] = t%BASE;
    }
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    bigint operator - (const bigint &a, const bigint &b)
    {
    bigint c;
    c.w[0]= a.w[0]+1;
    for(int i =1; i< c.w[0]; ++i)
    {
    int o=0;
    if(a.w[i]<b.w[i]){
    c.w[i+1]--;
    o=1;
    }
    c.w[i]+=a.w[i]-b.w[i]+o*BASE;
    }
    if (c.w[c.w[0]] == 0)
    --c.w[0];
    return c;
    }

    int convert(const bigint &a)
    {
    int ret = 0, power = 1;
    for (int i = 1; i <= a.w[0]; ++i, power *= BASE)
    ret += a.w[i] * power;
    return ret;
    }

    bool operator < (const bigint &a, const bigint &b)
    {
    if (a.w[0] != b.w[0])
    return a.w[0] < b.w[0];
    else
    for(int i = a.w[0]; i >= 1; --i)
    if (a.w[i] != b.w[i])
    return a.w[i] < b.w[i];
    return false;
    }

    bool operator > (const bigint &a, const bigint &b)
    {
    return b < a;
    }

    bool operator == (const bigint &a, const bigint &b)
    {
    return (!(a < b)) && (!(b < a));
    }

    bool operator <= (const bigint &a, const bigint &b)
    {
    return !(b < a);
    }

    bool operator >= (const bigint &a, const bigint &b)
    {
    return !(a < b);
    }

    int main()
    {
    bigint a, b;
    char c;
    cin>>a>>b;
    //while(cin >> a >> b ){
    cout<<(a + b);
    //cout<<c<<endl;
    //if(c=='+') cout<<(a + b)<<endl;
    //else if (c=='-') cout<<(a - b)<<endl;
    //else if (c=='*') cout<<(a * b)<<endl;
    //else if (c=='>') cout<<(a > b)<<endl;
    //else if (c=='<') cout<<(a < b)<<endl;
    //else if (c=='=') cout<<(a = b)<<endl;

    //}
    return 0;
    }**

  • -1
    @ 2018-01-30 18:28:11

    #include<stdio.h>
    #include<string.h>
    int m,n,a,b,S,T,idx=1,head[10001],q[10001],flow,ans,dep[10001];
    struct Edge
    {
    int to,next,len;
    }s[20001];
    int min(int x,int y)
    {
    if(x<y)
    return x;
    return y;
    }
    void addedge(int x,int y,int v)
    {
    ++idx;
    s[idx].to=y;
    s[idx].len=v;
    s[idx].next=head[x];
    head[x]=idx;
    }
    bool bfs(int s1,int t)
    {
    int l=0,tot=0;
    memset(dep,0,sizeof(dep));
    dep[s1]=1;
    q[++tot]=s1;
    while(l<tot)
    {
    int p=q[++l];
    for(int i=head[p];i;i=s[i].next)
    if(s[i].len&&!dep[s[i].to])
    {
    dep[s[i].to]=dep[p]+1;
    q[++tot]=s[i].to;
    }
    }
    return dep[t]!=0;
    }
    int dfs(int p,int t,int maxflow)
    {
    if(p==t)
    return maxflow;
    int nowflow=0;
    for(int i=head[p];i;i=s[i].next)
    if(dep[s[i].to]==dep[p]+1&&s[i].len)
    {
    int tmp=dfs(s[i].to,t,min(maxflow-nowflow,s[i].len));
    nowflow+=tmp;
    s[i].len-=tmp;
    s[i^1].len+=tmp;
    }
    return nowflow;
    }
    int main()
    {
    scanf("%d%d",&m,&n);
    T=n+1;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
    if(a==-1&&b==-1)
    break;
    addedge(a,b,999999999);
    addedge(b,a,0);
    }
    for(int i=1;i<=m;i++)
    addedge(S,i,1),addedge(i,S,0);
    for(int i=m+1;i<=n;i++)
    addedge(T,i,0),addedge(i,T,1);
    while(bfs(S,T))
    {
    while(flow=dfs(S,T,999999999))
    ans+=flow;
    }
    if(ans!=0)
    {
    printf("%d\n",ans);
    for(int i=2;i<=idx;i+=2)
    if(s[i].to!=S&&s[i^1].to!=S&&s[i].to!=T&&s[i^1].to!=T&&s[i^1].len!=0)
    printf("%d %d\n",s[i^1].to,s[i].to);
    }
    else
    printf("No Solution!");
    }

信息

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