freesoul's blog

By freesoul, 9 years ago, In English
dp = [[0 for i in xrange(5005)] for i in xrange(5005)]
def f_f(c,t):
    if (dp[c][t] != 0): 
        return dp[c][t] - 1;
    if (t==1):
        return 1;
    ret = 0
    i = int(c/t)
    while(i >= 0):
        ret=ret+ f_f (c-i*t, t-1)
        if ret >= 1988:
            ret %= 1988
        i = i - 1
    dp[c][t] = 1 + ret
    return dp[c][t] - 1

while(1):
    o = raw_input();
    s = map(int,o.split())
    a = s[0]
    b = s[1]
    if (a == 0 and b == 0):
        break
    print f_f(a-b,b)

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By freesoul, history, 9 years ago, In English

Can somebdy pls help me about how to approach to this problem. http://www.spoj.com/problems/SPEC_SET/

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it