• Codeforces Beta Round #3 A. Shortest path of the king


    标题效果:

    鉴于国际棋盘两点,寻求同意的操作,是什么操作的最小数量,在操作过程中输出。




    解题思路:


    水题一个,见代码。



    以下是代码:

    #include <set>
    #include <map>
    #include <queue>
    #include <math.h>
    #include <vector>
    #include <string>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <iostream>
    #include <cctype>
    #include <algorithm>
    
    #define eps 1e-6
    #define pi acos(-1.0)
    #define inf 107374182
    #define inf64 1152921504606846976
    #define lc l,m,tr<<1
    #define rc m + 1,r,tr<<1|1
    #define zero(a) fabs(a)<eps
    #define iabs(x)  ((x) > 0 ? (x) : -(x))
    #define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))
    #define clearall(A, X) memset(A, X, sizeof(A))
    #define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))
    #define memcopyall(A, X) memcpy(A , X ,sizeof(X))
    #define max( x, y )  ( ((x) > (y)) ? (x) : (y) )
    #define min( x, y )  ( ((x) < (y)) ? (x) : (y) )
    
    using namespace std;
    
    int main()
    {
        char s1[3],s2[3];
        scanf("%s%s",&s1,&s2);
        char a,b;
        if(s1[0]>s2[0])a='L';
        else a='R';
        if(s1[1]>s2[1])b='D';
        else b='U';
        printf("%d
    ",max(iabs(s1[0]-s2[0]),iabs(s1[1]-s2[1])));
        if(iabs(s1[0]-s2[0])-iabs(s1[1]-s2[1])>0)
        {
            for(int i=0;i<iabs(s1[0]-s2[0])-iabs(s1[1]-s2[1]);i++)
            {
                printf("%c
    ",a);
            }
        }
        else if(iabs(s1[0]-s2[0])-iabs(s1[1]-s2[1])!=0)
        {
            for(int i=0;i<iabs(iabs(s1[0]-s2[0])-iabs(s1[1]-s2[1]));i++)
            {
                printf("%c
    ",b);
            }
        }
        for(int i=0;i<min(iabs(s1[0]-s2[0]),iabs(s1[1]-s2[1]));i++)
        {
            printf("%c%c
    ",a,b);
        }
        return 0;
    }
    



    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    Groovy Urlencode编码
    PowerShell导入自定义公共函数
    Groovy获取对象类型、属性
    adb名称操作模拟器
    《坚不可摧》——乔布斯演讲
    马拉松节奏跑(转载)
    马拉松配速
    什么是思考力三要素?(转载)
    Python解析JSON为实体
    excel宏的用法
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4831538.html
Copyright © 2020-2023  润新知