题解

1328 条题解

  • 0
    @ 2006-04-25 16:54:46

    var

    a,b:longint;

    begin

    readln(a,b);

    writeln(a+b);

    end.

  • 0
    @ 2006-10-14 20:27:12

    此题实质上非常复杂 全面考察到了数学史和计算机史 经典代数 常用计算与输入输出等等等等知识点

    考虑到题目的所有可能性 我们应当从计算机存储的二进制的角度来逐步考虑数的表示 以字节计数,采用多字节合用的方式表示一个大整数如今已经是高级程序语言编译器轻松可以达到的目标 可是为了加强对计算机计数的了解 此题可以考虑仍以最原始的方式进行计算——并且考虑最终将二进制数转变为十进制输出的全部过程 期间还考察了对ASCII码的熟悉程度

    此题实在经典 乃居家旅行必备之良题

    ( 2006-3-19 21:00:44 )

  • 0
    @ 2006-04-15 12:07:03

    var

    x,y:longint;

    begin

    readln(x,y);

    writeln(x+y);

    end.

  • 0
    @ 2006-04-12 20:58:02

    program k;

    var a,b,c:longint;

    begin

    readln(a,b);

    c:=a+b;

    writeln(c);

    end.

  • 0
    @ 2006-03-23 17:06:49

    var

    a,b:longint;

    begin

    readln(a,b);

    writeln('A+B=',a+b);

    end.

    这样只要两个变量,节省了空间,加快了运行速度!

  • 0
    @ 2006-03-19 21:00:44

    此题实质上非常复杂 全面考察到了数学史和计算机史 经典代数 常用计算与输入输出等等等等知识点

    考虑到题目的所有可能性 我们应当从计算机存储的二进制的角度来逐步考虑数的表示 以字节计数,采用多字节合用的方式表示一个大整数如今已经是高级程序语言编译器轻松可以达到的目标 可是为了加强对计算机计数的了解 此题可以考虑仍以最原始的方式进行计算——并且考虑最终将二进制数转变为十进制输出的全部过程 期间还考察了对ASCII码的熟悉程度

    此题实在经典 乃居家旅行必备之良题

  • 0
    @ 2006-03-19 16:43:11

    program kao;

    var a,b,c:real;

    begin

    read(a,b);

    c:=a+b;

    writeln(c);

    end.

  • 0
    @ 2006-03-16 19:06:28

    var

    x,y:integer;

    s:int64;

    begin

    read(x,y);

    s:=x+y;

    write(s);

    end.

  • 0
    @ 2006-02-10 18:41:59

    var c:word;

      a,b:longint;

    begin

    c:=a+b;

    writeln(c);

    end.

  • 0
    @ 2006-02-08 14:24:58

    var c : word;

    a, b : longint;

    begin

    c:=a+b;

    writeln(c);

    end.

  • -1
    @ 2025-04-10 20:26:57
    #include<bits/stdc++.h>
    using namespace std;
    struct sb{
        int a,b;
    };
    int main(){
        sb n;
        cin>>n.a>>n.b;
        cout<<n.a+n.b<<'\n';
    }
    
    • @ 2025-07-09 21:46:23

      结构体类型名不文明,差评 \(+\) 举报

  • -1
    @ 2024-12-10 22:28:18

    一道很好的 树状数组 题。

    #include <iostream>
    #include <string>
    #include <cstdio>
    using namespace std;
    
    struct Array {
        int *arr;
        int lowbit(int x) {
            return x & -x;
        }
        int getsum(int x) { //计算[1,x]区间中数列和
            int ret=0;
            while(x>0) {
                ret+=arr[x];
                x=x-lowbit(x);
            }
            return ret;
        }
        
        void plus(int x, int v) { //把第x个元素增加v
            while(x <= (int)sizeof(arr)) {
                arr[x]=arr[x]+v;
                x=x+lowbit(x);
            }
        }
        
        Array() {}
        Array(int length, int arr[]) {
            this->arr=new int[length+1];
            for(int i=1; i<=length; i++) this->arr[i]=0;
            for(int i=1; i<=length; i++) plus(i, arr[i-1]);
        }
        ~Array()=default;
    };
    
    int main() {
        Array a;
        int arr[2];
        scanf("%d%d", &arr[0], &arr[1]);
        a=Array(2, arr);
        printf("%d\n", a.getsum(2));
        return 0;
    }
    
  • -1
    @ 2024-12-09 16:51:14

    我有两篇题解:
    给新手小白的:

    #include<iostream>
    int main(){
        int a,b;
        scanf("%d %d",&a,&b);
        printf("%d",a+b);
        return 0;
    }
    

    这是给大佬的:

    #include<iostream>
    #include<string>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    const int N = 1005;
    struct bign
    {
        int len,s[N];
        bign()  {  memset(s,0,sizeof(s));  len=1;  }
        bign(int num)  {  *this=num; }
        bign(char *num) { *this=num; }
        bign operator =(int num)
        {
            char c[N];
            sprintf(c,"%d",num);
            *this=c;
            return *this;
        }
        bign operator =(const char *num)
        {
            len=strlen(num);
            for (int i=0;i<len;i++) s[i]=num[len-1-i]-'0';
            return *this;
        }
        string str()
        {
            string res="";
            for (int i=0;i<len;i++) res=(char)(s[i]+'0')+res;
            return res;
        }
        void clean()
        {
            while (len>1&&!s[len-1]) len--;
        }
        bign operator +(const bign &b)
        {
            bign c;    
            c.len=0;
            for (int i=0,g=0;g||i<len||i<b.len;i++)
            {
                int x=g;
                if (i<len) x+=s[i];
                if (i<b.len) x+=b.s[i];
                c.s[c.len++]=x%10;
                g=x/10;
            }
            return c;
        }
        bign operator -(const bign &b)
        {
            bign c;
            c.len=0;
            int x;     
            for (int i=0,g=0;i<len;i++)
            {
                x=s[i]-g;
                if (i<b.len) x-=b.s[i];
                if (x>=0) g=0;
                else{          
                    x+=10;
                    g=1;
                };
                c.s[c.len++]=x;
            }
            c.clean();
            return c;
        }
        bign operator *(const bign &b)
        {
            bign c;
            c.len=len+b.len;
            for (int i=0;i<len;i++) for (int j=0;j<b.len;j++) c.s[i+j]+=s[i]*b.s[j];
            for (int i=0;i<c.len-1;i++) { c.s[i+1]+=c.s[i]/10; c.s[i]%=10; }
            c.clean();
            return c;  
        }
        bool operator <(const bign &b)
        {
            if (len!=b.len) return len<b.len;
            for (int i=len-1;i>=0;i--)
                 if (s[i]!=b.s[i]) return s[i]<b.s[i];
            return false;
        }
        bign operator +=(const bign &b)
        {
            *this=*this+b;
            return *this;
        }
        bign operator -=(const bign &b)
        {
            *this=*this-b;
            return *this;
        }  
    };
    istream& operator >>(istream &in,bign &x)
    {
      string s;
      in>>s;
      x=s.c_str();
      return in;
    }
    ostream& operator <<(ostream &out,bign &x)
    {
        out<<x.str();
        return out;
    }
    int main(){
        bign a,b,c;
        ios::sync_with_stdio(false);
        cin>>a>>b;
        c=a+b;
        cout<<c<<endl;
        return 0;
    }
    

    希望这篇题解有助于大家!

  • -1
    @ 2024-10-04 09:25:02

    A + B问题实在是太难了,不过用LCT还是能解出来的,代码如下
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    struct node
    {
    int data,rev,sum;
    node *son[2],*pre;
    bool judge();
    bool isroot();
    void pushdown();
    void update();
    void setson(node *child,int lr);
    }lct[233];
    int top,a,b;
    node *getnew(int x)
    {
    node *now=lct+ ++top;
    now->data=x;
    now->pre=now->son[1]=now->son[0]=lct;
    now->sum=0;
    now->rev=0;
    return now;
    }
    bool node::judge(){return pre->son[1]==this;}
    bool node::isroot()
    {
    if(pre==lct)return true;
    return !(pre->son[1]==this||pre->son[0]==this);
    }
    void node::pushdown()
    {
    if(this==lct||!rev)return;
    swap(son[0],son[1]);
    son[0]->rev^=1;
    son[1]->rev^=1;
    rev=0;
    }
    void node::update(){sum=son[1]->sum+son[0]->sum+data;}
    void node::setson(node *child,int lr)
    {
    this->pushdown();
    child->pre=this;
    son[lr]=child;
    this->update();
    }
    void rotate(node *now)
    {
    node *father=now->pre,*grandfa=father->pre;
    if(!father->isroot()) grandfa->pushdown();
    father->pushdown();now->pushdown();
    int lr=now->judge();
    father->setson(now->son[lr^1],lr);
    if(father->isroot()) now->pre=grandfa;
    else grandfa->setson(now,father->judge());
    now->setson(father,lr^1);
    father->update();now->update();
    if(grandfa!=lct) grandfa->update();
    }
    void splay(node *now)
    {
    if(now->isroot())return;
    for(;!now->isroot();rotate(now))
    if(!now->pre->isroot())
    now->judge()==now->pre->judge()?rotate(now->pre):rotate(now);
    }
    node *access(node *now)
    {
    node *last=lct;
    for(;now!=lct;last=now,now=now->pre)
    {
    splay(now);
    now->setson(last,1);
    }
    return last;
    }
    void changeroot(node *now)
    {
    access(now)->rev^=1;
    splay(now);
    }
    void connect(node *x,node *y)
    {
    changeroot(x);
    x->pre=y;
    access(x);
    }
    void cut(node *x,node *y)
    {
    changeroot(x);
    access(y);
    splay(x);
    x->pushdown();
    x->son[1]=y->pre=lct;
    x->update();
    }
    int query(node *x,node *y)
    {
    changeroot(x);
    node *now=access(y);
    return now->sum;
    }
    int main()
    {
    scanf("%d%d",&a,&b);
    node *A=getnew(a);
    node *B=getnew(b);
    //连边 Link
    connect(A,B);
    //断边 Cut
    cut(A,B);
    //再连边orz Link again
    connect(A,B);
    printf("%d\n",query(A,B));
    return 0;
    }

  • -1
    @ 2024-05-12 16:21:12

    可以尝试用时间复杂度为\( O(a^a+b^b*2) \)的算法去做(doge

  • -1
    @ 2023-10-20 11:07:14

    IAKIOI

  • -1
    @ 2023-07-28 20:12:45

    自己想

  • -1
    @ 2023-05-26 17:02:17

    让评测姬爆炸的代码

    #include<bits/stdc++.h>
    using namespace std;
    long long a[32768][32768];
    int main(){
        int x,y;
        cin>>x>>y;
        for(int i=1;i<=32767;i++)
            for(int j=1;j<=32767;j++)
                a[i][j] = i+j;
        cout<<a[x][y];
        return 0;
    }
    
  • -1
    @ 2022-09-25 19:37:27

    本蒟蒻第一次写题解
    望大佬多多指导
    本代码使用C风格输入输出printf和scanf PS:仍属于C++语言
    话不多说直接上代码

    #include <cstdio>//引用头文件
    int a,b;//定义全局变量a,b
    int main()//主函数
    {
        scanf("%d%d",&a,&b);//输入a,b
        printf("%d",a+b);//输出a+b
        return 0;//返回值(可忽略)
    }
    
  • -1
    @ 2022-09-25 16:44:38

    1

信息

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