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;
}


svtter
209 声望37 粉丝

更喜欢原型开发