• Day algorithm [more] • The fifth fifteen literacy: What is constant card?

Preface ▎

  Xiao Bian has been that card before the pronunciation is constant ka chang shu, actually qia chang shu.

  Little friends do not want to read wrong.

▎ defined

  Card program is constant, though generally refers to a progressive program complexity can be acceptable, but due to realize / algorithm itself large time constant factor, such that the ends can not operate within the time limit OI / ICPC algorithms competition.

  Constant is known as among the most amazing computer algorithm contest a Class A digital main features focused on the murky, overtime sometimes make high level players or fans of hyperspace. (Copy from Baidu)

  Therefore, the number of those Cattleya card is not constant in number theory of what, only one meaning: Your program may be O (the n- 2 ), but the solution to a problem is O (the n- 2 ), but you can not Why had it? The reason is that constant too big, say others may have to + 1ms, then you may have to 2ms, so your program will be small constant card out, so when we write code, we should take some measures in order to avoid being card constants.
▎ Solutions
  Here are some options:
  • Multi-use scanf and printf, cin and cout very slow, should not be mixed.
  • Ternary operator? : Faster than if else, but faster than if.
  • The number of frequently used with a usage register, and inline, but it is possible to deposit variable CPU register, to reduce the time.

Guess you like

Origin www.cnblogs.com/TFLS-gzr/p/11394752.html