Encrypted Message Decoder

Hard
math modular-arithmetic decryption number-theory
Problem Description

Decode an encrypted message where each character is encoded using the formula: encoded_value = (position × ASCII_value) % 127. Given the encoded values and their positions, recover the original message.

Input Format
First line contains n (message length). Second line contains n space-separated integers representing encoded values.
Output Format
The decoded original message as a string.
Constraints
• 1 ≤ n ≤ 1000
• 0 ≤ encoded values < 127
• Position starts from 1 (1-indexed)
• Original characters are printable ASCII (32-126)
• Formula: encoded = (position × ASCII) % 127
Sample Input/Output
Input:
5
72 101 108 108 111
Output:
Hello
Explanation

For position 1: 72 = (1 × ASCII_H) % 127 → ASCII_H = 72. For position 2: 101 = (2 × ASCII_e) % 127 → ASCII_e = 101/2 = 50.5, but we need integer, so we find ASCII_e such that (2 × ASCII_e) % 127 = 101.

Solution Hints
160
Points
4000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback