新手求问,,,,,为什么oj一直过不去

新手,,,,为什么oj总是一直不过,,,
和网上正确代码对比了一样的输入对应输出一模一样。。可为什么oj不过呢
http://cxsjsx.openjudge.cn/2015warpractice/A/

 #include <iostream>
using namespace std;
#include <math.h>
#include <string>
#include <assert.h>
#include <limits.h>

#define N 1000

char _time[5];

enum Warrior {
    dragon, ninja, iceman
    , lion, wolf
};

const string name_table[5] = { "dragon", "ninja", "iceman", "lion", "wolf" };
const int next_warrior_table_1[5] = { 2,0,3,4,1 };
const int next_warrior_table_2[5] = { 1,2,4,0,3 };

void print_time(int time) {
    if (time <= 9) {
        _time[0] = time + '0';
        _time[1] = '0';
        _time[2] = '0';
        for (int i = 2; i >= 0; i--)
            printf("%c", _time[i]);
    }
    else if (time <= 99) {
        _time[0] = time % 10 + '0';
        _time[1] = (time / 10) + '0';
        _time[2] = '0';
        for (int i = 2; i >= 0; i--)
            printf("%c", _time[i]);
    }
    else if (time <= 999){
        _time[0] = time % 10 + '0';
        _time[1] = (time / 10) % 10 + '0';
        _time[2] = (time / 100) + '0';
        for (int i = 2; i >= 0; i--)
            printf("%c", _time[i]);
    }
    else if (time <= 9999) {
        _time[0] = time % 10 + '0';
        _time[1] = (time / 10) % 10 + '0';
        _time[2] = (time / 100) % 10 + '0';
        _time[3] = (time / 1000) + '0';
        for (int i = 3; i >= 0; i--)
            printf("%c", _time[i]);
    }
    else {
        _time[0] = time % 10 + '0';
        _time[1] = (time / 10) % 10 + '0';
        _time[2] = (time / 100) % 10 + '0';
        _time[3] = (time / 1000) % 10 + '0';
        _time[4] = (time / 10000) + '0';
        for (int i = 4; i >= 0; i--)
            printf("%c", _time[i]);
    }

}

int main() {
    int n, M1, M2, time;
    bool run1, run2;
    int warrior_total_1, warrior_total_2;
    int warrior_num_1[5], warrior_num_2[5];
    int next_warrior_1, next_warrior_2;
    int lifepoint_table[5];

    cin >> n;
    for (int k = 1; k <= n; k++) {



        cin >> M1;
        M2 = M1;
        time = 0;
        run1 = run2 = true;
        warrior_total_1 = warrior_total_2 = 0;
        for (int i = 0; i < 5; i++)
            warrior_num_1[i] = warrior_num_2[i] = 0;
        next_warrior_1 = 2;
        next_warrior_2 = 3;
        for (int i = 0; i < 5; i++)
            cin >> lifepoint_table[i];
        printf("Case:%d\n", k);
        for (; run1 || run2; time++) {

            if (run1) {
                if (M1 - lifepoint_table[next_warrior_1] < 0) {
                    int i = 1;
                    for (; i <= 4; i++) {
                        next_warrior_1 = next_warrior_table_1[next_warrior_1];
                        if (M1 - lifepoint_table[next_warrior_1] >= 0)
                            break;
                    }
                    if (i == 5) {
                        print_time(time);
                        printf(" red headquarter stops making warriors\n");
                        run1 = false;
                    }
                }

                if (run1) {
                    M1 -= lifepoint_table[next_warrior_1];
                    warrior_total_1++;
                    warrior_num_1[next_warrior_1]++;

                    print_time(time);
                    printf(" red %s %d born with strengh %d,%d %s in red headquarter\n",
                        name_table[next_warrior_1].c_str(), warrior_total_1, lifepoint_table[next_warrior_1],
                        warrior_num_1[next_warrior_1], name_table[next_warrior_1].c_str());

                    next_warrior_1 = next_warrior_table_1[next_warrior_1];

                    //printf("%d : %d %d %d %d %d\n", time, warrior_num_1[0], warrior_num_1[1], warrior_num_1[2]
                    //  , warrior_num_1[3], warrior_num_1[4], warrior_num_1[5]);

                }

            }

            if (run2) {
                if (M2 - lifepoint_table[next_warrior_2] < 0) {
                    int i = 0;
                    for (; i <= 4; i++) {
                        next_warrior_2 = next_warrior_table_2[next_warrior_2];
                        if (M2 - lifepoint_table[next_warrior_2] >= 0)
                            break;
                    }
                    if (i == 5) {
                        run2 = false;
                        print_time(time);
                        printf(" blue headquarter stops making warriors\n");
                    }
                }
                if (run2) {
                    M2 -= lifepoint_table[next_warrior_2];
                    warrior_total_2++;
                    warrior_num_2[next_warrior_2]++;

                    print_time(time);
                    printf(" blue %s %d born with strengh %d,%d %s in blue headquarter\n",
                        name_table[next_warrior_2].c_str(), warrior_total_2, lifepoint_table[next_warrior_2], 
                        warrior_num_2[next_warrior_2], name_table[next_warrior_2].c_str());

                    next_warrior_2 = next_warrior_table_2[next_warrior_2];

                    //printf("%d : %d %d %d %d %d\n", time, warrior_num_2[0], warrior_num_2[1], warrior_num_2[2]
                    //  , warrior_num_2[3], warrior_num_2[4], warrior_num_2[5]);

                }

            }




        }
    }
}
ios

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐