Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

void name_transformation(int year, int month, int day);

int main(void) {
  int a, b, c; /*aは年、 bは月、cは日*/
  while ((scanf("%d %d %d\\n", &a, &b, &c)) != EOF) {
    name_transformation(a, b, c);
  }
  return 0;
}

void name_transformation(int year, int month, int day) {
  int gengou;
  if (year >= 1989) {
    if (year > 1989) {
      gengou = year - 1988;
      printf("heisei %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 1) {
        if (month > 1) {
          printf("heisei 1 %d %d\\n", month, day);
        } else {
          if (day >= 8) {
            printf("heisei 1 1 %d\\n", day);
          } else {
            printf("showa 64 1 %d\\n", day);
          }
        }
      }
    }
  } else if (year >= 1926) {
    if (year > 1926) {
      gengou = year - 1925;
      printf("showa %d %d %d\\n", gengou, month, day);
    } else {
      if (month == 12) {
        if (day >= 25) {
          printf("showa 1 12 %d\\n", day);
        } else {
          printf("taisho 15 12 %d\\n", day);
        }
      }
    }
  } else if (year >= 1912) {
    if (year > 1912) {
      gengou = year - 1911;
      printf("taisho %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 7) {
        if (month > 7) {
          printf("taisho 1 %d %d\\n", month, day);
        } else {
          if (day >= 30) {
            printf("taisho 1 7 %d\\n", day);
          } else {
            printf("meiji 45 7 %d\\n", day);
          }
        }
      }
    }
  } else if (year >= 1868) {
    if (year > 1868) {
      gengou = year - 1867;
      printf("meiji %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 9) {
        if (month > 9) {
          printf("meiji 1 %d %d\\n", month, day);
        } else {
          if (day >= 8) {
            printf("meiji 1 9 %d\\n", day);
          } else {
            printf("pre-meiji\\n");
          }
        }
      }
    }
  } else {
    printf("pre-meiji\\n");
  }
}


Error: TLE

Fixed submission:

#include <stdio.h>

void name_transformation(int year, int month, int day);

int main(void) {
  while (1) {
    int a, b, c; /*aは年、bは月、cは日を表す*/
    scanf("%d %d %d", &a, &b, &c);
    if ((a && b && c) != EOF) {
      name_transformation(a, b, c);
    } else {
      break;
    }
  }
  return 0;
}

void name_transformation(int year, int month, int day) {
  int gengou;
  if (year >= 1989) {
    if (year > 1989) {
      gengou = year - 1988;
      printf("heisei %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 1) {
        if (month > 1) {
          printf("heisei 1 %d %d\\n", month, day);
        } else {
          if (day >= 8) {
            printf("heisei 1 1 %d\\n", day);
          } else {
            printf("syowa 64 1 %d\\n", day);
          }
        }
      }
    }
  } else if (year >= 1926) {
    if (year > 1926) {
      gengou = year - 1925;
      printf("showa %d %d %d\\n", gengou, month, day);
    } else {
      if (month == 12) {
        if (day >= 25) {
          printf("syowa 1 12 %d\\n", day);
        } else {
          printf("taisho 15 12 %d\\n", day);
        }
      }
    }
  } else if (year >= 1912) {
    if (year > 1912) {
      gengou = year - 1911;
      printf("taisho %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 7) {
        if (month > 7) {
          printf("taisho 1 %d %d\\n", month, day);
        } else {
          if (day >= 30) {
            printf("taisho 1 7 %d\\n", day);
          } else {
            printf("meiji 45 7 %d\\n", day);
          }
        }
      }
    }
  } else if (year >= 1868) {
    if (year > 1868) {
      gengou = year - 1867;
      printf("meiji %d %d %d\\n", gengou, month, day);
    } else {
      if (month >= 9) {
        if (month > 9) {
          printf("meiji 1 %d %d\\n", month, day);
        } else {
          if (day >= 8) {
            printf("meiji 1 9 %d\\n", day);
          } else {
            printf("pre-meiji\\n");
          }
        }
      }
    }
  } else {
    printf("pre-meiji\\n");
  }
}