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

Автор ashwanikumarsharma, история, 4 часа назад, По-английски

I was doing a Project Euler Problems, motivated by Radewoosh and aryanc403. I came across a problem that required finding the sum of the digits of a factorial. I still can't figure out how to implement it in C++ (there must be some way), but in Python, even a one-day beginner in coding can write this code easily. On one hand, Python makes our life easy, but on the other hand, it kills coding. There is literally no Integer Overflow. You can even do multiplication of a 100-digit number by another 100-digit number. Now I understand why some people do some specific problems in Python and the rest in C++ during Codeforces contests.

a = 1
for i in range(2, 101):
    a *= i

ans = 0
while a > 0:
    ans += (a % 10)
    a //= 10

print(ans)
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Python is really good if you are starting out.

But for experienced Problem solvers, C++ is really good and Python kind of loses its value cause Python is really slow and the main reason people use Python for Competetive Programming is that it is easy to implement.

But for experienced Problem solvers, that doesn't matter.