题解

1325 条题解

  • 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
    @ 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

  • -1
    @ 2022-09-11 17:47:30
    #include<iostream>
    using namespace std;
    int fuck, shit;
    int main() {cin>>fuck>>shit;cout<<fuck+shit;//caonima
                            return 0-0;
                         }
    //fuck your bitrch
    
  • -1
    @ 2022-08-31 21:26:22

    这道题还蛮难的
    不过用线段树很简单
    注:出自洛谷*神一般的世界
    *

    #include<cstdio>
    #include<algorithm>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<iostream>
    using namespace std;
    struct node{
        int val,l,r;
    };
    node t[5];
    int a[5],f[5];
    int n,m;
    void init(){
        for(int i=1;i<=2;i++){
            scanf("%d",&a[i]);
        }
    }
    void build(int l,int r,int node){//这是棵树
        t[node].l=l;t[node].r=r;t[node].val=0;
        if(l==r){
            f[l]=node;
            t[node].val=a[l];
            return;
        }
        int mid=(l+r)>>1;
        build(l,mid,node*2);
        build(mid+1,r,node*2+1);
        t[node].val=t[node*2].val+t[node*2+1].val;
    }
    void update(int node){
        if(node==1)return;
        int fa=node>>1;
        t[fa].val=t[fa*2].val+t[fa*2+1].val;
        update(fa);
    }
    int find(int l,int r,int node){
        if(t[node].l==l&&t[node].r==r){
            return t[node].val;
        }
        int sum=0;
        int lc=node*2;int rc=lc+1;
        if(t[lc].r>=l){
            if(t[lc].r>=r){
                sum+=find(l,r,lc);
            }
            else{
                sum+=find(l,t[lc].r,lc);
            }
        }
        if(t[rc].l<=r){
            if(t[rc].l<=l){
                sum+=find(l,r,rc);
            }
            else{
                sum+=find(t[rc].l,r,rc);
            }
        }
        return sum;
    }
    int main(){
        init();
        build(1,2,1);
        printf("%d",find(1,2,1));
    }
    
  • -1
    @ 2022-08-23 11:28:43

    按照题意模拟即可

  • -1
    @ 2022-08-23 10:28:00
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a,b;//定义变量
        cin>>a>>b;//输入
        cout<<a+b;//输出
        return 0;
    }
    
    
  • -1
    @ 2022-07-16 22:28:00

    \(\rule{10000000mm}{100000000mm}\)

信息

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