ACM - Uvaoj 刷题

10055

  1. WA了两次之后好好or vice versa:反之亦然。
  2. 另外,int型的最大为2^31-1(符号位)
c#include <iostream>
#include <stdio.h>

using namespace std;

#define lln long long

int main()
{
    lln a, b;
    lln t;
    while(~scanf("%lld %lld", &a, &b))
    {
        t = a - b;
        printf("%lld\n", t > 0 ? t : -t);
    }
    return 0;
}

10071

看了看就是求路程的两倍。。

c#include <iostream>
#include <stdio.h>

using namespace std;

#define lln long long

int main()
{
    int v, t;
    while(~scanf("%d%d", &v, &t))
    {
        printf("%d\n", v*t*2);
    }
    return 0;
}

10030

中间那个数没用。

c#include <iostream>
#include <stdio.h>

using namespace std;

#define lln long long

int main()
{
    int f, n, i;
    int size, num, value;
    int sum;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &f);
        sum = 0;
        for(i = 0; i < f; i++)
        {
            scanf("%d%d%d", &size, &num, &value);
            sum += size * value;
        }
        printf("%d\n", sum);
    }
    return 0;
}

401

没有考虑len == 1的情况-=,再一个就是整数>0, 对应的bool为true.

c#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

#define lln long long

const int maxn = 100;

char letter[128];

char fix[4][100];

void init()
{
    letter['A'] = 'A'; letter['E'] = '3'; letter['H'] = 'H';
    letter['I'] = 'I'; letter['J'] = 'L'; letter['L'] = 'J';
    letter['M'] = 'M'; letter['O'] = 'O'; letter['S'] = '2';
    letter['T'] = 'T'; letter['U'] = 'U'; letter['V'] = 'V';
    letter['W'] = 'W'; letter['X'] = 'X'; letter['Y'] = 'Y';
    letter['Z'] = '5'; letter['1'] = '1'; letter['2'] = 'S';
    letter['3'] = 'E'; letter['5'] = 'Z'; letter['8'] = '8';
    strcpy(fix[0], " -- is not a palindrome.");
    strcpy(fix[1], " -- is a regular palindrome.");
    strcpy(fix[2], " -- is a mirrored string.");
    strcpy(fix[3], " -- is a mirrored palindrome.");
}

char trans(char a)
{
    return letter[a];
}

int judgeMir(char *s)
{
    int len = strlen(s);
    if(len == 1)
        return s[0] == trans(s[0]);
    for(int i = 0; i < len/2; i++)
        if(s[i] != trans(s[len-i-1]))
            return 0;
    return 1;
}

int judgeCycle(char *s)
{
    int len = strlen(s);
    if(len == 1)
        return 1;
    for(int i = 0; i < len/2; i++)
        if(s[i] != s[len-i-1])
        {
            return 0;
        }
    return 1;
}

int main()
{
    char s[maxn];
    init();
    while(~scanf("%s", s))
    {
        int i = judgeCycle(s) + 2 * judgeMir(s);
        printf("%s", s);
        puts(fix[i]);
        printf("\n");
    }

    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值