Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:38:23+00:00 2026-05-28T17:38:23+00:00

I was practicing the dynamic programming problem on SPOJ. But I have no idea

  • 0

I was practicing the dynamic programming problem on SPOJ. But I have no idea how to solve this one.

Can anyone please help ME in solving http://www.spoj.pl/problems/ACODE/ problem on SPOJ
Thanks!

Alice and Bob need to send secret messages to each other and are
discussing ways to encode their messages:

Alice: “Let’s just use a very simple code: We’ll assign ‘A’ the code
word 1, ‘B’ will be 2, and so on down to ‘Z’ being assigned 26.”

Bob: “That’s a stupid code, Alice. Suppose I send you the word ‘BEAN’
encoded as 25114. You could decode that in many different ways!”
Alice: “Sure you could, but what words would you get? Other than
‘BEAN’, you’d get ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ and ‘BEKD’. I think
you would be able to figure out the correct decoding. And why would
you send me the word ‘BEAN’ anyway?” Bob: “OK, maybe that’s a bad
example, but I bet you that if you got a string of length 5000 there
would be tons of different decodings and with that many you would find
at least two different ones that would make sense.” Alice: “How many
different decodings?” Bob: “Jillions!”

For some reason, Alice is still unconvinced by Bob’s argument, so she
requires a program that will determine how many decodings there can be
for a given string using her code.

Input

Input will consist of multiple input sets. Each set will consist of a
single line of at most 5000 digits representing a valid encryption
(for example, no line will begin with a 0). There will be no spaces
between the digits. An input line of ‘0’ will terminate the input and
should not be processed.

Output

For each input set, output the number of possible decodings for the
input string. All answers will be within the range of a 64 bit signed
integer.

Example

Input:

25114 1111111111 3333333333 0

Output:

6 89 1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:38:25+00:00Added an answer on May 28, 2026 at 5:38 pm

    Starting from the left, do the following:

    1. Find how many words the sequence can be interpreted as (call that say x[k]) up to this point using a finite number of the values for previous calculated for points along the sequence.
    2. Move to the next point.

    If you still can’t get it, you can take a look at the Welcome to Code Jam problem. It somewhat similar and has readily available explanations for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been practicing for an upcoming programming competition and I have stumbled across a
I am practicing recursion and I can't see why this method does not seem
Been practicing with those system calls, but I stucked into this code: #include <stdio.h>
I was practicing SRM Problems in Topcoder.I came across this problem Problem Statement: Today
I am practicing with PHP and AJAX but I have some problems! I'm trying
I am practicing StringToByteArray() on VS2005. But throw exception. Could you please tell me
I'm practicing some examples on model-view programming and have a query why the colors
i'm practicing c and looking to use visual studio. but can I write console
so im practicing the STL string class, but i can not figure out why
i'm practicing php at nowadays. i have one question. i see one = on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.