|
|
вернуться в форумgood solution def SUM(n): ans=0 while n: ans+=n%10 n/=10 return ans def main(): n=int(raw_input()) n/=2 m={} for i in range(0,10**n): try: m[SUM(i)]+=1 except: m[SUM(i)]=1 ans=0 for i in m: ans+=m[i]*(m[i]) #print i, m[i] print ans main()
I used dictionary ( in c/c++ it's map) Edited by author 25.07.2014 18:56 Edited by author 25.07.2014 18:57 |
|
|