题解

1323 条题解

  • 0
    @ 2015-04-22 20:57:47

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

  • 0
    @ 2015-04-21 19:35:51

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

  • 0
    @ 2015-03-28 11:18:43

    #include<iostream>
    using namespace std;
    int main()
    {
    int n;
    cin>>n;
    for(int i=0;i<=n;i+=3)
    {
    int i1=i;
    bool i2=false;
    while(i1>0)
    {
    if(i1%10==5)
    {
    i2=true;
    break;

    }
    i1/=10;
    }
    if(i2)cout<<i<<endl;

    }

    return 0;

    }

  • 0
    @ 2015-03-21 17:52:48

    #include<iostream>
    using namespace std ;

    int main()
    {
    while(1)
    {
    int x,y ,t ;
    cout<<"请输入x,y"<<endl ;
    cin>>x>>y ;
    t=x+y ;
    cout<<t<<endl ;
    }
    }
    为什么不通过

  • 0
    @ 2015-03-17 22:05:55

    。。。

  • 0
    @ 2015-03-17 14:05:03

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<climits>
    using namespace std;

    //斐波那契结点ADT
    struct FibonacciHeapNode {
    int key; //结点
    int degree; //度
    FibonacciHeapNode * left; //左兄弟
    FibonacciHeapNode * right; //右兄弟
    FibonacciHeapNode * parent; //父结点
    FibonacciHeapNode * child; //第一个孩子结点
    bool marked; //是否被删除第1个孩子
    };

    typedef FibonacciHeapNode FibNode;

    //斐波那契堆ADT
    struct FibonacciHeap {
    int keyNum; //堆中结点个数
    FibonacciHeapNode * min;//最小堆,根结点
    int maxNumOfDegree; //最大度
    FibonacciHeapNode * * cons;//指向最大度的内存区域
    };

    typedef FibonacciHeap FibHeap;

    /*****************函数申明*************************/
    //将x从双链表移除
    inline void FibNodeRemove(FibNode * x);

    //将x堆结点加入y结点之前(循环链表中)
    void FibNodeAdd(FibNode * x, FibNode * y);

    //初始化一个空的Fibonacci Heap
    FibHeap * FibHeapMake() ;

    //初始化结点x
    FibNode * FibHeapNodeMake();

    //堆结点x插入fibonacci heap中
    void FibHeapInsert(FibHeap * heap, FibNode * x);

    //将数组内的值插入Fibonacci Heap
    void FibHeapInsertKeys(FibHeap * heap, int keys[], int keyNum);

    //将值插入Fibonacci Heap
    static void FibHeapInsertKey(FibHeap * heap, int key);

    //抽取最小结点
    FibNode * FibHeapExtractMin(FibHeap * heap);

    //合并左右相同度数的二项树
    void FibHeapConsolidate(FibHeap * heap);

    //将x根结点链接到y根结点
    void FibHeapLink(FibHeap * heap, FibNode * x, FibNode *y);

    //开辟FibHeapConsolidate函数哈希所用空间
    static void FibHeapConsMake(FibHeap * heap);

    //将堆的最小结点移出,并指向其有兄弟
    static FibNode *FibHeapMinRemove(FibHeap * heap);

    //减小一个关键字
    void FibHeapDecrease(FibHeap * heap, FibNode * x, int key);

    //切断x与父节点y之间的链接,使x成为一个根
    static void FibHeapCut(FibHeap * heap, FibNode * x, FibNode * y);

    //级联剪切
    static void FibHeapCascadingCut(FibHeap * heap, FibNode * y);

    //修改度数
    void renewDegree(FibNode * parent, int degree);

    //删除结点
    void FibHeapDelete(FibHeap * heap, FibNode * x);

    //堆内搜索关键字
    FibNode * FibHeapSearch(FibHeap * heap, int key);

    //被FibHeapSearch调用
    static FibNode * FibNodeSearch(FibNode * x, int key);

    //销毁堆
    void FibHeapDestory(FibHeap * heap);

    //被FibHeapDestory调用
    static void FibNodeDestory(FibNode * x);

    //输出打印堆
    static void FibHeapPrint(FibHeap * heap);

    //被FibHeapPrint调用
    static void FibNodePrint(FibNode * x);
    /************************************************/

    //将x从双链表移除
    inline void FibNodeRemove(FibNode * x) {
    x->left->right = x->right;
    x->right->left = x->left;
    }

    /*
    将x堆结点加入y结点之前(循环链表中)
    a …… y
    a …… x …… y
    */
    inline void FibNodeAdd(FibNode * x, FibNode * y) {
    x->left = y->left;
    y->left->right = x;
    x->right = y;
    y->left = x;
    }

    //初始化一个空的Fibonacci Heap
    FibHeap * FibHeapMake() {
    FibHeap * heap = NULL;
    heap = (FibHeap *) malloc(sizeof(FibHeap));
    if (NULL == heap) {
    puts("Out of Space!!");
    exit(1);
    }
    memset(heap, 0, sizeof(FibHeap));
    return heap;
    }

    //初始化结点x
    FibNode * FibHeapNodeMake() {
    FibNode * x = NULL;
    x = (FibNode *) malloc(sizeof(FibNode));
    if (NULL == x) {
    puts("Out of Space!!");
    exit(1);
    }
    memset(x, 0, sizeof(FibNode));
    x->left = x->right = x;
    return x;
    }

    //堆结点x插入fibonacci heap中
    void FibHeapInsert(FibHeap * heap, FibNode * x) {
    if (0 == heap->keyNum) {
    heap->min = x;
    } else {
    FibNodeAdd(x, heap->min);
    x->parent = NULL;
    if (x->key < heap->min->key) {
    heap->min = x;
    }
    }
    heap->keyNum++;
    }

    //将数组内的值插入Fibonacci Heap
    void FibHeapInsertKeys(FibHeap * heap, int keys[], int keyNum) {
    for (int i = 0; i < keyNum; i++) {
    FibHeapInsertKey(heap, keys[i]);
    }
    }

    //将值插入Fibonacci Heap
    static void FibHeapInsertKey(FibHeap * heap, int key) {
    FibNode * x = NULL;
    x = FibHeapNodeMake();
    x->key = key;
    FibHeapInsert(heap, x);
    }

    //抽取最小结点
    FibNode * FibHeapExtractMin(FibHeap * heap) {
    FibNode * x = NULL, * z = heap->min;
    if (z != NULL) {

    //删除z的每一个孩子
    while (NULL != z->child) {
    x = z->child;
    FibNodeRemove(x);
    if (x->right == x) {
    z->child = NULL;
    } else {
    z->child = x->right;
    }
    FibNodeAdd(x, z);//add x to the root list heap
    x->parent = NULL;
    }

    FibNodeRemove(z);
    if (z->right == z) {
    heap->min = NULL;
    } else {
    heap->min = z->right;
    FibHeapConsolidate(heap);
    }
    heap->keyNum--;
    }
    return z;
    }

    //合并左右相同度数的二项树
    void FibHeapConsolidate(FibHeap * heap) {
    int D, d;
    FibNode * w = heap->min, * x = NULL, * y = NULL;
    FibHeapConsMake(heap);//开辟哈希所用空间
    D = heap->maxNumOfDegree + 1;
    for (int i = 0; i < D; i++) {
    *(heap->cons + i) = NULL;
    }

    //合并相同度的根节点,使每个度数的二项树唯一
    while (NULL != heap->min) {
    x = FibHeapMinRemove(heap);
    d = x->degree;
    while (NULL != *(heap->cons + d)) {
    y = *(heap->cons + d);
    if (x->key > y->key) {//根结点key最小
    swap(x, y);
    }
    FibHeapLink(heap, y, x);
    *(heap->cons + d) = NULL;
    d++;
    }
    *(heap->cons + d) = x;
    }
    heap->min = NULL;//原有根表清除

    //将heap->cons中结点都重新加到根表中,且找出最小根
    for (int i = 0; i < D; i++) {
    if (*(heap->cons + i) != NULL) {
    if (NULL == heap->min) {
    heap->min = (heap->cons + i);
    } else {
    FibNodeAdd(
    (heap->cons + i), heap->min);
    if ((*(heap->cons + i))->key < heap->min->key) {
    heap->min = *(heap->cons + i);
    }//if(<)
    }//if-else(==)
    }//if(!=)
    }//for(i)
    }

    //将x根结点链接到y根结点
    void FibHeapLink(FibHeap * heap, FibNode * x, FibNode *y) {
    FibNodeRemove(x);
    if (NULL == y->child) {
    y->child = x;
    } else {
    FibNodeAdd(x, y->child);
    }
    x->parent = y;
    y->degree++;
    x->marked = false;
    }

    //开辟FibHeapConsolidate函数哈希所用空间
    static void FibHeapConsMake(FibHeap * heap) {
    int old = heap->maxNumOfDegree;
    heap->maxNumOfDegree = int(log(heap->keyNum * 1.0) / log(2.0)) + 1;
    if (old < heap->maxNumOfDegree) {
    //因为度为heap->maxNumOfDegree可能被合并,所以要maxNumOfDegree+1
    heap->cons = (FibNode **) realloc(heap->cons,
    sizeof(FibHeap *) * (heap->maxNumOfDegree + 1));
    if (NULL == heap->cons) {
    puts("Out of Space!");
    exit(1);
    }
    }
    }

    //将堆的最小结点移出,并指向其有兄弟
    static FibNode *FibHeapMinRemove(FibHeap * heap) {
    FibNode *min = heap->min;
    if (heap->min == min->right) {
    heap->min = NULL;
    } else {
    FibNodeRemove(min);
    heap->min = min->right;
    }
    min->left = min->right = min;
    return min;
    }

    //减小一个关键字
    void FibHeapDecrease(FibHeap * heap, FibNode * x, int key) {
    FibNode * y = x->parent;
    if (x->key < key) {
    puts("new key is greater than current key!");
    exit(1);
    }
    x->key = key;

    if (NULL != y && x->key < y->key) {
    //破坏了最小堆性质,需要进行级联剪切操作
    FibHeapCut(heap, x, y);
    FibHeapCascadingCut(heap, y);
    }
    if (x->key < heap->min->key) {
    heap->min = x;
    }
    }

    //切断x与父节点y之间的链接,使x成为一个根
    static void FibHeapCut(FibHeap * heap, FibNode * x, FibNode * y) {
    FibNodeRemove(x);
    renewDegree(y, x->degree);
    if (x == x->right) {
    y->child = NULL;
    } else {
    y->child = x->right;
    }
    x->parent = NULL;
    x->left = x->right = x;
    x->marked = false;
    FibNodeAdd(x, heap->min);
    }

    //级联剪切
    static void FibHeapCascadingCut(FibHeap * heap, FibNode * y) {
    FibNode * z = y->parent;
    if (NULL != z) {
    if (y->marked == false) {
    y->marked = true;
    } else {
    FibHeapCut(heap, y, z);
    FibHeapCascadingCut(heap, z);
    }
    }
    }

    //修改度数
    void renewDegree(FibNode * parent, int degree) {
    parent->degree -= degree;
    if (parent-> parent != NULL) {
    renewDegree(parent->parent, degree);
    }
    }

    //删除结点
    void FibHeapDelete(FibHeap * heap, FibNode * x) {
    FibHeapDecrease(heap, x, INT_MIN);
    FibHeapExtractMin(heap);
    }

    //堆内搜索关键字
    FibNode * FibHeapSearch(FibHeap * heap, int key) {
    return FibNodeSearch(heap->min, key);
    }

    //被FibHeapSearch调用
    static FibNode * FibNodeSearch(FibNode * x, int key) {
    FibNode * w = x, * y = NULL;
    if (x != NULL) {
    do {
    if (w->key == key) {
    y = w;
    break;
    } else if (NULL != (y = FibNodeSearch(w->child, key))) {
    break;
    }
    w = w->right;
    } while (w != x);
    }
    return y;
    }

    //销毁堆
    void FibHeapDestory(FibHeap * heap) {
    FibNodeDestory(heap->min);
    free(heap);
    heap = NULL;
    }

    //被FibHeapDestory调用
    static void FibNodeDestory(FibNode * x) {
    FibNode * p = x, *q = NULL;
    while (p != NULL) {
    FibNodeDestory(p->child);
    q = p;
    if (p -> left == x) {
    p = NULL;
    } else {
    p = p->left;
    }
    free(q->right);
    }
    }

    //输出打印堆
    static void FibHeapPrint(FibHeap * heap) {
    printf("The keyNum = %d\n", heap->keyNum);
    FibNodePrint(heap->min);
    puts("\n");
    };

    //被FibHeapPrint调用
    static void FibNodePrint(FibNode * x) {
    FibNode * p = NULL;
    if (NULL == x) {
    return ;
    }
    p = x;
    do {
    printf(" (");
    printf("%d", p->key);
    if (p->child != NULL) {
    FibNodePrint(p->child);
    }
    printf(") ");
    p = p->left;
    }while (x != p);
    }
    int main() {int a,b;
    FibHeap* heap = NULL;
    FibNode* x = NULL;
    heap=FibHeapMake();
    scanf("%d%d",&a,&b);
    FibHeapInsertKey(heap,a+b);
    x=FibHeapExtractMin(heap);
    printf("%d\n",x->key);
    FibHeapDestory(heap);
    return 0;
    }

  • 0
    @ 2015-02-13 18:50:49

    #include <stdio.h>

    int main()
    {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",a+b);
    return 0;
    }

  • 0
    @ 2015-02-13 10:33:31

    public static void main(String args[]){
    Scanner in=new Scanner(System.in);
    int a=in.nextInt();
    int b=in.nextInt();
    System.out.println(a+b);
    }

  • 0
    @ 2015-02-05 10:07:55

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }很简单的

  • 0
    @ 2015-02-05 10:07:45

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-05 10:07:44

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-05 10:07:43

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-05 10:07:38

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-05 10:07:36

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-05 10:07:21

    #include<stdio.h>
    int main()
    {
    int i,s,t;
    scanf("%d %d",&s,&t);
    i=0;
    i=s+t;
    printf("%d",i);
    return 0;
    }

  • 0
    @ 2015-02-02 18:19:54

    记录信息
    评测状态 Accepted
    题目 P1000 A+B Problem
    递交时间 2015-02-02 18:19:11
    代码语言 Pascal
    评测机 VijosEx
    消耗时间 52 ms
    消耗内存 744 KiB
    评测时间 2015-02-02 18:19:11
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 15 ms, mem = 744 KiB, score = 10
    测试数据 #1: Accepted, time = 7 ms, mem = 744 KiB, score = 10
    测试数据 #2: Accepted, time = 15 ms, mem = 744 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 744 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 740 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 740 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 744 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 740 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 740 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 740 KiB, score = 10
    Accepted, time = 52 ms, mem = 744 KiB, score = 100
    代码
    var
    a,b:int64;
    begin
    readln(a,b);
    writeln(a+b);
    end.

  • 0
    @ 2015-01-20 12:29:28

    type
    data=record
    x,y:longint;
    end;
    var
    head,tail,ans,xx,yy,m,n:longint;
    map:array[1..50,1..50] of char;
    q:array[1..30000] of data;
    dist:array[1..30000] of longint;
    v:array[1..50,1..50] of boolean;
    procedure init;
    var
    i,j:longint;
    begin
    readln(m,n);
    ans:=999999999;
    head:=1;tail:=1;
    for i:=1 to m do
    begin
    for j:=1 to n do
    begin
    read(map[i,j]);
    if map[i,j]='S' then
    begin
    q[tail].x:=i;
    q[tail].y:=j;
    v[i,j]:=true;
    end;
    end;
    readln;
    end;
    end;
    procedure check;
    begin
    if dist[head]<ans then ans:=dist[head];
    end;

    procedure bfs;
    var
    i:longint;
    begin
    while head<=tail do
    begin
    xx:=q[head].x;
    yy:=q[head].y;
    for i:=xx+1 to m do
    begin
    if map[i,yy]='B' then
    if not v[i-1,yy] then
    begin
    v[i-1,yy]:=true;
    inc(tail);
    q[tail].x:=i-1;
    q[tail].y:=yy;
    dist[tail]:=dist[head]+1;
    break;
    end
    else break;
    if map[i,yy]='E' then
    begin
    check;
    break;
    end;
    end;

    for i:= xx-1 downto 1 do
    begin
    if map[i,yy]='B' then
    if not v[i+1,yy] then
    begin
    v[i+1,yy]:=true;
    inc(tail);
    q[tail].x:=i+1;
    q[tail].y:=yy;
    dist[tail]:=dist[head]+1;
    break;
    end
    else break;
    if map[i,yy]='E' then
    begin
    check;
    break;
    end;
    end;
    for i:=yy+1 to n do
    begin
    if map[xx,i]='B' then
    if not v[xx,i-1] then
    begin
    v[xx,i-1]:=true;
    inc(tail);
    q[tail].x:=xx;
    q[tail].y:=i-1;
    dist[tail]:=dist[head]+1;
    break;
    end
    else break;
    if map[xx,i]='E' then
    begin
    check;
    break;
    end;
    end;
    for i:=yy-1 downto 1 do
    begin
    if map[xx,i]='B' then
    if not v[xx,i+1] then
    begin
    v[xx,i+1]:=true;
    inc(tail);
    q[tail].x:=xx;
    q[tail].y:=i+1;
    dist[tail]:=dist[head]+1;
    break;
    end
    else break;
    if map[xx,i]='E' then
    begin
    check;
    break;
    end;
    end;
    inc(head);
    end;
    end;

    begin
    init;
    bfs;
    if ans=999999999 then writeln('No')
    else
    begin
    writeln('Yes');
    writeln(ans);
    end;
    end.

  • 0
    @ 2014-12-25 19:02:17

    难度为9的题原来是这个样子。O(∩_∩)O

  • 0
    @ 2014-10-06 16:30:37

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

  • 0
    @ 2014-10-05 15:14:11

    var p,q,c:array[1..10000]of longint;
    i,j,l1,l2,l3,k:longint;
    a,b:string;
    begin
    read(a);
    readln;
    read(b);
    l1:=length(a);
    l2:=length(b);
    for i:=1 to 10000 do
    begin
    p[i]:=0;
    q[i]:=0;
    c[i]:=0;
    end;
    for i:=l1 downto 1 do p[l1-i+1]:=ord(p[l1])-ord('0');
    for i:=l2 downto 1 do q[l2-i+1]:=ord(q[l2])-ord('0');
    if l1>l2 then l3:=l1 else l3:=l2;
    for i:=1 to l3 do
    begin
    c[i]:=p[i]+q[i]+c[i];
    if c[i]>10 then
    begin
    c[i+1]:=c[i] div 10;
    c[i]:=c[i] mod 10;
    end;
    end;
    for i:=10000 downto 1 do
    if i<>0 then break;
    for j:=i downto 1 do write(c[i]);
    end.

信息

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