結果
| 問題 |
No.3115 One Power One Kill
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 11:50:13 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,026 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 11,904 KB |
| 実行使用メモリ | 43,920 KB |
| 最終ジャッジ日時 | 2025-04-19 11:50:20 |
| 合計ジャッジ時間 | 7,245 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 19 |
ソースコード
# Constants
MOD = 1000000007
MOD2 = 456
# Function to calculate power with modulo (modular exponentiation)
def mod_pow(base, exp, mod):
result = 1
while exp > 0:
if exp % 2 == 1:
result = (result * base) % mod
base = (base * base) % mod
exp //= 2
return result
# Function to calculate gcd using Euclid's algorithm
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def main():
# Initial value of X is given as 100
X = 100
# Read inputs for A and B
A, B = map(int, input().split())
# Step 1: Calculate Y = A^B % (10^9 + 7)
Y = mod_pow(A, B, MOD)
print(f"Judge is Y = {A}^{B} % (10^9 + 7) = {Y}")
# Step 2: Calculate K = gcd(X, Y)
K = gcd(X, Y)
print(f"Judge is K = gcd(X, Y) = {K}")
# Step 3: Calculate X' = X^K % 456
X_prime = mod_pow(X, K, MOD2)
print(f"Judge is X' = X^{K} % 456 = {X_prime}")
# Output final result
print(f"Final X' = {X_prime}")
if __name__ == "__main__":
main()