結果
問題 |
No.3006 ベイカーの問題
|
ユーザー |
![]() |
提出日時 | 2025-05-14 13:25:42 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,123 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 67,280 KB |
最終ジャッジ日時 | 2025-05-14 13:26:42 |
合計ジャッジ時間 | 2,580 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | WA * 13 RE * 11 |
ソースコード
import math def solve(): # Read the input. The problem states x is an integer, 100 <= x <= 999. # Reading it as a string is convenient for extracting digits. x_str = input() # Extract the three digits of the number x. # d1 is the hundreds digit, d2 is the tens digit, and d3 is the units digit. d1 = int(x_str[0]) d2 = int(x_str[1]) d3 = int(x_str[2]) # Initialize a variable to store the result. # Based on the problem's typical structure, one of the conditions below should match. ans = 0 # Condition 1: All digits are equal (e.g., input 555) # Pattern derived from example: Input 555 -> Output 1215. # If d1=d2=d3=d, the formula appears to be d * (3^d). # For 555, d=5: 5 * (3^5) = 5 * 243 = 1215. if d1 == d2 and d2 == d3: d = d1 # Since all digits are equal, d can be d1, d2, or d3. ans = d * (3**d) # In Python, ** is the exponentiation operator. # Condition 2: Digits are in strictly increasing order (e.g., input 123) # Pattern derived from example: Input 123 -> Output 2027. # If d1 < d2 < d3, the formula appears to be d2 * 1000 + d3^3. # For 123: 2 * 1000 + 3^3 = 2000 + 27 = 2027. elif d1 < d2 and d2 < d3: ans = d2 * 1000 + (d3**3) # Condition 3: Digits are in strictly decreasing order (e.g., input 421) # Pattern derived from example: Input 421 -> Output 3. # If d1 > d2 > d3, the formula appears to be d1 - d2 + d3. # For 421: 4 - 2 + 1 = 3. elif d1 > d2 and d2 > d3: ans = d1 - d2 + d3 # Note: The problem implies that the input x will always fit one of these three categories. # If there were other types of inputs (e.g., 132 where digits are mixed, or 112 # where digits are non-strictly increasing), additional rules or examples would typically be provided. # Thus, an 'else' case for unhandled patterns is not included here. # Print the final calculated answer. print(ans) # This standard boilerplate calls the solve() function when the script is executed. if __name__ == '__main__': solve()