Блог пользователя anupam

Автор anupam, история, 5 лет назад, По-английски

Initially I use GNU C++17 when I submit codes. I submitted code for 235A — LCM Challenge and got WA on test 61 using GNU C++17. Then again I submitted the same code in GNU C++14 and got Accepted. My submissions are here,

GNU C++17: 78659557 (Wrong answer on test 61)

GNU C++14: 78659665 (Accepted)

I found no explanation of it and thinking about what if it happened in contest time. Can you suggest me any reason? Thank you so much!

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится +38 Проголосовать: не нравится

C++17 adds the functions std::lcm and std::gcd. In C++17 your code actually calls std::lcm(int,int) which returns an int, leading to overflow. In C++14 such a function doesn't exist so the program uses your function which doesn't overflow.