Input in Problem A
1000000000 987654321 123456789
When typing
A, B, C = map(int, input().split())
ans = (A * (A + 1) * B * (B + 1) * C * (C + 1) / 8) % 998244353
print(int(ans))
I answered like this, but WA came out. Looking at other people's AC answers
A, B, C = map(int, input().split())
ans = (A * (A + 1) * B * (B + 1) * C * (C + 1) // 8) % 998244353
print(int(ans))
There was only a difference between / or //.
print(type(A * (A + 1) * B * (B + 1) * C * (C + 1)/8))
print(A * (A + 1) * B * (B + 1) * C * (C + 1)//8)
The result is ...
1.8584458350497822e+51
1858445835049782285757026664950217712384527500000000
You can see that // is calculated accurately, while / is truncated in the middle. The reason is that it has been changed to a float type.
This knowledge is important, but it was too late to come up with how to solve the problem. It hurts to drop Problem A, which can be solved in an instant, even though I solved Problem B with much effort.
Recommended Posts