submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s115429369
p00008
Wrong Answer
import sys for n in sys.stdin: ans = 0 for (a,m,d) in [(int(n)/i,int(n)%i,i) for i in range(1,10) if int(n)/i <= 4]: if (a==4 and m==0): ans += 1 elif (a%2==1): ans += 4 elif (a==2): ans += m+1 print ans
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s550033575
p00008
Wrong Answer
ans=0 q=input() for i in range(10): for j in range(10): for x in range(10): for y in range(10): if i+j+x+y == q: ans+=1 print ans
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s382529310
p00008
Wrong Answer
import itertools n = int(raw_input()) c = 0 for a in itertools.product(range(10), repeat=4): if sum(a) == n: c += 1 print c
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s015483601
p00008
Wrong Answer
import math num = int(raw_input()) count = 0 for a in range(0, 10): for b in range(0, 10): for c in range(0, 10): for d in range(0, 10): if a+b+c+d == num: count += 1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s303276779
p00008
Wrong Answer
while 1: try: n = input() x = 0 if n < 37: for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == n: x += 1 print x except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s678345504
p00008
Wrong Answer
# -*- coding: utf-8 -*- import sys def mCn(m, n): ret = 1 for i in xrange(n): ret *= m - i ret /= i + 1 return ret for line in ["35"]:#sys.stdin.readlines(): List = map(int, line.strip().split()) n = List[0] ans = 0 for i in xrange(10000): a = i / 1000; i %= 1000 b = i / 100 ; i %= 100 c = i / 10 ; i %= 10 d = i if(a + b + c + d == n): ans += 1 print ans
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s098467747
p00008
Wrong Answer
while True: try: n = int(raw_input()) count = 0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): i+j+k+l == n count += 1 print count except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s072091747
p00008
Wrong Answer
N = int(raw_input()) print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == N])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s335566631
p00008
Wrong Answer
from itertools import product while 1: try: print len([1 for x in product(range(10), repeat=4) if sum(x) == input()]) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s878237952
p00008
Accepted
while True: try: n=int(input()) ans=0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==n:ans+=1 print(ans) except:break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s184268195
p00008
Accepted
while True: try: n = int(raw_input()) cnt = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if n == a+b+c+d: cnt+=1 print cnt except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s157344167
p00008
Accepted
while True: try: n = int(input()) except EOFError: break ret=0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==n: ret+=1 print(ret)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s900517607
p00008
Accepted
while True: try: n=int(input()) ans=0 for a in range(0,10): for b in range(0,10): for c in range(0,10): if 0<=(n-(a+b+c))<=9: ans+=1 print(ans) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s073830772
p00008
Accepted
try: while True: n = int(input()) count = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == n: count += 1 print(count) except: pass
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s972309686
p00008
Accepted
import sys x = [0]*51 for a in xrange(0,10): for b in xrange(0,10): for c in xrange(0,10): for d in xrange(0,10): x[a+b+c+d]+=1 for i in sys.stdin: print x[int(i)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s071987185
p00008
Accepted
# 累積計算 from itertools import product if __name__ == "__main__": while True: try: col = 0 n = int(input()) #print(n) if n > 36: print(0) else: for a, b, c, d in product(range(0, 10), repeat=4): if a + b + c + d == n: col += 1 else: pass print(col) except EOFError: break # escape from while loop pass #
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s741404439
p00008
Accepted
while(True): try: ans = 0 n = input() for i in range(10): for j in range(10): for k in range(10): for l in range(10): if(i + j + k + l == n): ans += 1 print(ans) except Exception: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s524392141
p00008
Accepted
while True: ans = 0 try: n = input() except (EOFError): break for a in range(10): atmp = n - a if(-1 < atmp and atmp<28): for b in range(10): btmp = atmp - b if(-1 < btmp and btmp<19): for c in range(10): d = btmp - c if(-1 < d and d<10): ans += 1 #print (a, b, c, d) print ans
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s333289850
p00008
Accepted
while True: try: #(a,b,c,d)=map(int,raw_input().split()) n=input() cnt=0 for a in xrange(10): for b in xrange(10): for c in xrange(10): for d in xrange(10): if a+b+c+d==n: cnt+=1 print(cnt) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s090755559
p00008
Accepted
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys money = 100000 for s in sys.stdin: count = 0 d = int(s) for i1 in range(10): if i1 > d: pass for i2 in range(10): if i1 + i2 > d: pass for i3 in range(10): if i1 + i2 + i3 > d: pass for i4 in range(10): if i1 + i2 + i3 + i4 > d: pass if i1 + i2 + i3 + i4 == d: count += 1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s341035600
p00008
Accepted
import math def sum_of(v_cnt, n): if v_cnt == 1: if 0 <= n <= 9: return 1 else: return 0 else: result = 0 for v in range(10): result += sum_of(v_cnt - 1, n - v) return result import sys for line in sys.stdin: n = int(line) print sum_of(4, n)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s898395260
p00008
Accepted
while True: try: cnt=0 i=int(input()) for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==i: cnt+=1 print(cnt) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s745631936
p00008
Accepted
x=[0]*51 for a in range(10): for b in range(10): for c in range(10): for d in range(10): x[a+b+c+d]+=1 while True: try: print(x[int(input())]) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s275587924
p00008
Accepted
while True: try: n=int(input()) s=range(10) cnt=0 for i in s: for j in s: for k in s: for l in s: if i+j+k+l==n: cnt+=1 print(cnt) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s024374832
p00008
Accepted
import sys import itertools for line in sys.stdin: n = int(line) cnt = 0 for i in itertools.product([i for i in range(10)], repeat=4): if n == sum(i):cnt += 1 print(cnt)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s192744320
p00008
Accepted
#! /usr/bin/python3 while True: try: s=int(input()) n=0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if s == i+j+k+l: n+=1 print(n) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s705074833
p00008
Accepted
while True: count = 0 try: n = int(input()) except: break for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == n: count += 1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s784615910
p00008
Accepted
while True: try: n = int(raw_input()) except EOFError: break x = [0]*51 for a in xrange(0,10): for b in xrange(0,10): for c in xrange(0,10): for d in xrange(0,10): x[a+b+c+d] +=1 print x[n]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s919084019
p00008
Accepted
import sys for n in sys.stdin: n=int(n) count=0 for i1 in xrange(10): for i2 in xrange(10): for i3 in xrange(10): for i4 in xrange(10): if(i1+i2+i3+i4 == n): count+=1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s235355146
p00008
Accepted
while True: try: n = int(input()) count = 0 for a in range(0,10): for b in range(0,10): for c in range(0,10): for d in range(0,10): if a+b+c+d==n: count+=1 print(count) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s232964347
p00008
Accepted
from itertools import product while True: try: n = int(input()) except: break print(sum(a+b+c+d==n for a,b,c,d in product(range(10), repeat=4)))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s816497854
p00008
Accepted
import sys for line in sys.stdin: n = int(line) cnt = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if(n == a + b + c + d): cnt += 1 print cnt
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s350213169
p00008
Accepted
# -*- coding: utf-8 -*- import sys money = 100000 for s in sys.stdin: count = 0 d = int(s) for i in range(10): if i > d : pass for j in range(10): if i + j > d: pass for k in range(10): if i + j + k : pass for l in range(10): if i + j + k + l > d : pass if i + j + k + l == d : count += 1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s081556155
p00008
Accepted
import itertools l = [0,1,2,3,4,5,6,7,8,9] while True: try: N = int(raw_input()) res = 0 for element in itertools.product(l,repeat=4): if sum(element) == N: res += 1 print res except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s980069130
p00008
Accepted
# -*- coding: utf-8 -*- import itertools while True: try: n = int ( input ( ) ) except EOFError: break r = 0 for ( i, j, k ) in itertools.product ( range ( 10 ), range ( 10 ), range ( 10 ) ): r += ( 0 <= n - i - j - k < 10 ) print ( r )
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s035046221
p00008
Accepted
while(True): a = 0 try: n = input() except EOFError: break n=int(n) if n > 36: print(0) continue elif n==36: print(1) continue b = n for i in range(10): if n-i==0: a=a+1 #print("(%d,0,0,0)"%(i)) break for j in range(10): if n-i-j==0: a=a+1 #print("(%d,%d,0,0)"%(i,j)) break for k in range(10): b = n-i-j-k if b>=0 and b<=9: a=a+1 #print("(%d,%d,%d,%d)"%(i,j,k,b)) continue elif b > 9: continue else: break print(a)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s579816920
p00008
Accepted
while True: try: s=int(input()) i=0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==s: i+=1 print(i) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s020266694
p00008
Accepted
# -*- coding: utf-8 -*- while(True): try: n = int(raw_input()) sum = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if (a + b + c + d == n): sum += 1 print sum except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s393160760
p00008
Accepted
def get_input(): while True: try: yield ''.join(raw_input()) except EOFError: break ar = [0] * 51 for i in range(10): for j in range(10): for k in range(10): for l in range(10): ar[i + j + k + l] += 1 for a in list(get_input()): print ar[int(a)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s375309787
p00008
Accepted
import sys import itertools for l in sys.stdin: k=[a for a in range(10)] print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s619627096
p00008
Accepted
import sys import itertools for l in sys.stdin: k=[a for a in xrange(10)] print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s701509994
p00008
Accepted
import sys,itertools k=[0,1,2,3,4,5,6,7,8,9] for l in sys.stdin:print[sum(x) for x in list(itertools.product(k,k,k,k))].count(int(l))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s451810015
p00008
Accepted
import sys,itertools k=range(10) for l in sys.stdin:print[sum(x)for x in list(itertools.product(k,k,k,k))].count(int(l))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s912704014
p00008
Accepted
import sys def f(s,d,g,c): if d>3:return c for n in range(10): if s+n==g:return c+1 elif s+n>g:return c else:c=f(s+n,d+1,g,c) return c for l in sys.stdin: print f(0,0,int(l),0)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s866357438
p00008
Accepted
import sys def f(s,d,g,c): if d>3:return c for n in xrange(10): if s+n==g:return c+1 elif s+n>g:return c else:c=f(s+n,d+1,g,c) return c for l in sys.stdin: print f(0,0,int(l),0)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s662200702
p00008
Accepted
import sys r=range(10) x=[0]*51 for a in r: for b in r: for c in r: for d in r: x[a+b+c+d]+=1 for l in sys.stdin: print x[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s664207643
p00008
Accepted
import sys r=xrange(10) x=[0]*51 for a in r: for b in r: for c in r: for d in r: x[a+b+c+d]+=1 for l in sys.stdin: print x[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s409403407
p00008
Accepted
import sys x=[0]*51 for a in xrange(10): for b in xrange(10): for c in xrange(10): for d in xrange(10): x[a+b+c+d]+=1 for l in sys.stdin: print x[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s933674216
p00008
Accepted
import sys s=[0]*51 for a in range(10): for b in range(10): for c in range(10): for d in range(10): s[a+b+c+d]+=1 for l in sys.stdin:print s[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s163294984
p00008
Accepted
import sys,itertools k=range(10) s=[0]*51 for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1 for l in sys.stdin:print s[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s907178231
p00008
Accepted
import sys,itertools k=xrange(10) s=[0]*51 for n in [sum(x)for x in list(itertools.product(k,k,k,k))]:s[n]+=1 for l in sys.stdin:print s[int(l)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s856097871
p00008
Accepted
import sys for input in sys.stdin: count = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == int(input): count += 1 print(count)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s366125957
p00008
Accepted
while 1: try: n=int(raw_input()) except EOFError: break print len([1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if i+j+k+l==n])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s277498447
p00008
Accepted
while(True): counter=0 try: date=int(input()) except: break for i in range(10): for j in range(10): for k in range(10): for l in range(10): if(date==(i+j+k+l)): counter+=1 print(counter)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s217658689
p00008
Accepted
import sys while True: n = sys.stdin.readline() cnt = 0 if n: for a in range(10): for b in range(10): for c in range(10): for d in range(10): if (a + b + c + d == int(n)): cnt += 1 print cnt else: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s675124428
p00008
Accepted
# coding: utf-8 #Problem Name: Sum of 4 Integers #ID: tabris #Mail: t123037@kaiyodai.ac.jp pairs = {i:0 for i in range(51)} for i in range(10): for j in range(10): for k in range(10): for l in range(10): pairs[i+j+k+l] += 1 while True: try: n = int(raw_input()) print pairs[n] except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s261115067
p00008
Accepted
from itertools import product while True: try: n = int(input()) except: break count = sum(a + b + c + d == n for a, b, c, d in product(range(10), repeat=4)) print(count)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s292962284
p00008
Accepted
import sys import math while True: try: n = (int)(input()) res = 0 for i in range(0,10): for j in range(0,10): for k in range(0,10): for l in range(0,10): if (i+j+k+l == n): res += 1 print (res) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s483016923
p00008
Accepted
import sys for line in sys.stdin.readlines(): n = int(line) count = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == n: count += 1 print(count)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s611739849
p00008
Accepted
class Solution(object): def combinationSum(self, target): candidates = [] for i in range(10): candidates.append(i) stack = [(0, 0, [])] result = [] while stack: total, start, res = stack.pop() if total == target and len(res) == 4: result.append(res) elif len(res) > 4: continue if total == 0 and len(res) == 4: continue for i in range(start, len(candidates)): t = total + candidates[i] if t > target: break stack.append((t, i, res + [candidates[i]])) return result def duplicated(self, nums, i, j): for t in range(i, j): if nums[t] == nums[j]: return False return True def recursion(self, nums, i, n, result): if i == n - 1: temp = [] for k in range(0, n): temp.append(nums[k]) result.append(temp) else: for k in range(i, n): if self.duplicated(nums, i ,k): temp = nums[k] #swap nums[k] = nums[i] nums[i] = temp self.recursion(nums, i + 1, n, result) temp = nums[k] #swap nums[k] = nums[i] nums[i] = temp def permuteUnique(self, nums): result = [] self.recursion(nums, 0, len(nums), result) return result # s = Solution() # combination = s.combinationSum(35) # m = 0 # for i in range(len(combination)): # m += len(s.permuteUnique(combination[i])) # print m while True: try: n = int(raw_input()) s = Solution() combination = s.combinationSum(n) m = 0 for i in range(len(combination)): m += len(s.permuteUnique(combination[i])) print m except (EOFError): break # b = map(int, s2.split())
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s438052370
p00008
Accepted
import sys for n in sys.stdin: ret = 0 for a in xrange(10): for b in xrange(10): for c in xrange(10): for d in xrange(10): if a+b+c+d == int(n): ret += 1 print ret
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s499824954
p00008
Accepted
while True: try: n = int(raw_input()) ans = 0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if i+j+k+l == n: ans += 1 print ans except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s502804228
p00008
Accepted
import sys lines = sys.stdin.readlines() for line in lines: inp = int(line) s = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==inp: s+=1 print (s)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s231598592
p00008
Accepted
import sys for line in sys.stdin: n = int(line) ans = 0 a=b=c=d=0 while True: if d==10: c+=1 d=0 if c==10: b+=1 c=0 if b==10: a+=1 b=0 if a == 10: break #print "%d+%d+%d+%d"%(a,b,c,d) s = a+b+c+d if s == n: ans+=1 d+=1 print ans
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s610385040
p00008
Accepted
import sys for line in sys.stdin: n = int(line) cnt = 0 if n <= 36: for i in xrange(10): for j in xrange(10): for k in xrange(10): for l in xrange(10): if i + j + k + l == n: cnt += 1 print cnt
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s135270278
p00008
Accepted
while True: try: n = int(raw_input()) except EOFError: break count = 0 for a in range(0, 10): for b in range(0, 10): for c in range(0, 10): for d in range(0, 10): if (a + b + c + d) == n: count += 1 print count
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s880327623
p00008
Accepted
def count(num): l1=[] for a in range (10): for b in range(10): for c in range (10): for d in range (10): l1.append([a,b,c,d]) l1=list(filter(lambda x: sum(x)==num,l1)) return(len(l1)) while True: try: print(count(int(input()))) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s960306763
p00008
Accepted
import sys ans=[] def sumint(lp,ttl): if (ttl > lp*9) | (ttl < 0): return 0 elif lp == 1: return 1 else: a = 0 for n in range(0,10) : a += sumint(lp - 1,ttl - n) return a for i in sys.stdin: ans.append(sumint(4,int(i))) print('\n'.join(map(str,ans)))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s165146909
p00008
Accepted
while 1: try: n = input() x = 0 if n < 37: for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == n: x += 1 print x except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s840876157
p00008
Accepted
while 1: try: n = input() x = 0 if n < 50: for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == n: x += 1 print x except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s985087631
p00008
Accepted
tbl = [0] * 51 for i in range(10): for j in range(10): tbl[i + j] += 1 try: while 1: n = int(input()) res = 0 for i in range(n + 1): res += tbl[i] * tbl[n - i] print(res) except Exception: pass
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s385119052
p00008
Accepted
while True: try: n=int(input()) cnt=0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d==n: cnt+=1 print(cnt) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s493045045
p00008
Accepted
while True: try: n=int(input()) cnt=0 for a in range(10): for b in range(10): for c in range(10): d = n-(a+b+c) if 0<=d<=9: cnt+=1 print(cnt) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s401126203
p00008
Accepted
while True: try: n=int(input()) cnt=0 for a in range(10): if a<=n: for b in range(10): if b<=n: for c in range(10): if c<=n: d = n-(a+b+c) if 0<=d<=9: cnt+=1 else: break else: break else: break print(cnt) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s643507812
p00008
Accepted
import sys def output(x): count = 0 for i in xrange(10): for j in xrange(10): for k in xrange(10): for l in xrange(10): if i+j+k+l == x: count += 1 print count if __name__ == "__main__": for i in sys.stdin: num = int(i) output(num)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s688894325
p00008
Accepted
#!/usr/bin/env python3 import itertools import sys def operation(n): count = 0 for a, b, c, d in itertools.product(range(10), repeat=4): if a + b + c + d == n: count += 1 print(count) def main(): for l in sys.stdin: n = int(l.strip()) operation(n) if __name__ == '__main__': main()
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s484106703
p00008
Accepted
import sys import itertools def func(n): count = 0 for a, b, c, d in itertools.product(range(10), repeat=4): if a + b + c + d == n: count += 1 return count def main(): for l in sys.stdin: n = int(l.strip()) print(func(n)) if __name__ == '__main__': main()
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s641556275
p00008
Accepted
#coding:utf-8 while True: try: count = 0 n = input() for a in xrange(0, 10): for b in xrange(0, 10): for c in xrange(0, 10): for d in xrange(0, 10): if a + b + c + d == n: count += 1 print(count) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s926364226
p00008
Accepted
# -*- coding: utf-8 -*- import sys sum = [0]*37 for a in range(10): for b in range(10): for c in range(10): for d in range(10): sum[a+b+c+d] += 1 for line in sys.stdin: n = int(line) if n >= 0 and n <= 36: print sum[n] else: print "0"
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s757721508
p00008
Accepted
import sys from itertools import product s = [sum(l) for l in product(range(10), repeat = 4)] ns = sys.stdin.readlines() for n in ns: print(s.count(int(n)))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s284551898
p00008
Accepted
#Sum of 4 Integers count = 0 while True: try: i = int(input()) for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == i: count += 1 print(count) count = 0 except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s939825919
p00008
Accepted
while 1: try: ct=0 n=input() for a in xrange(10): for b in xrange(10): for c in xrange(10): if 0<=n-(a+b+c)<=9: ct+=1 print(ct) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s173988441
p00008
Accepted
import sys flags = [0]*51 for a in range(10): for b in range(10): for c in range(10): for d in range(10): flags[a+b+c+d] += 1 for i in sys.stdin: print flags[int(i)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s871556034
p00008
Accepted
cnt = 0 def get_input(): while True: try: yield ''.join(input()) except EOFError: break if __name__ == '__main__': array = list(get_input()) for i in range(len(array)): for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == int(array[i]): cnt += 1 print(cnt) cnt = 0
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s343065710
p00008
Accepted
#!/usr/bin/env python # -*- coding: utf-8 -*- # def kai(num): x = 0 for i in range(10000): mk = str(i).zfill(4) if int(mk[0])+int(mk[1])+int(mk[2])+int(mk[3]) == num: x += 1 return x def main(): while True: try: num = int(input()) except: return else: print(kai(num)) if __name__ == '__main__': main()
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s383720006
p00008
Accepted
import sys import itertools for n in sys.stdin.readlines(): n = int(n) patterns = itertools.product(range(10), range(10), range(10), range(10)) ans = 0 for a, b, c, d in patterns: if a + b + c + d == n: ans +=1 print(ans)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s198672947
p00008
Accepted
import sys for i in sys.stdin: n = int(i) cnt = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == n: cnt += 1 break print(cnt)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s174576364
p00008
Accepted
import sys from itertools import product sum = [0] * 51 for i,j,k,l in product(range(10),repeat=4): sum[i+j+k+l] +=1 for i in sys.stdin: print(sum[int(i)])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s015037745
p00008
Accepted
import sys from itertools import product sum = [0] * 51 for k,l in product([i+j for i,j in product(range(10),repeat=2)],repeat=2): sum[k+l] += 1 for i in sys.stdin: print(sum[int(i)])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s175978156
p00008
Accepted
import sys import math def nCr(n, k): if 0 <= k <= n: nk,kk = 1,1 for t in range(1, min(k, n - k) + 1): nk = nk*n kk = kk*t n -= 1 return nk // kk else: return 0 p = [0] * 51 v = 0 for i in range(19): t = nCr(i+3, i) v = v + 4 * nCr(i-8,i-10) p[i] = t - v p[36-i] = p[i] for i in sys.stdin: print(p[int(i)])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s843102930
p00008
Accepted
ans=[] while True: try: k=int(input()) ct=0 for i in range(10000): tmp=str(i) while len(tmp)<4: tmp="0"+tmp tmp_2=0 for j in tmp: tmp_2+=int(j) if tmp_2==k: ct+=1 ans.append(ct) except: break for i in range(len(ans)): if i==len(ans)-1: print(ans[i],) else: print(ans[i])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s222158400
p00008
Accepted
ans=[] while True: try: k=int(input()) if k>18: k=36-k ct=0 for i in range(10000): tmp=str(i) while len(tmp)<4: tmp="0"+tmp tmp_2=0 for j in tmp: tmp_2+=int(j) if tmp_2==k: ct+=1 ans.append(ct) except: break for i in range(len(ans)): if i==len(ans)-1: print(ans[i],) else: print(ans[i])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s907494646
p00008
Accepted
while True: try: n = int(input()) cnt = 0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if i+j+k+l == n: cnt += 1 print(cnt) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s980499668
p00008
Accepted
while True: try: ans = 0 n = int(raw_input()) for i in range(10): for j in range(10): for k in range(10): for l in range(10): if i+j+k+l == n: ans += 1 print ans except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s544507384
p00008
Accepted
import sys def solve(n): ret = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a+b+c+d == n: ret += 1 return ret; for i in sys.stdin: print solve(int(i))
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s502872805
p00008
Accepted
import sys p = [0] * 51 v = 0 for i in range(19): t = (i+3)*(i+2)*(i+1)//6 v = v + 2 * (i-8) * (i-9) if i > 9 else 0 p[i] = t - v p[36-i] = p[i] for i in sys.stdin: print(p[int(i)])
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s669733280
p00008
Accepted
while True: try: n = int(input()) except: exit() m = 9 c = 0 def loop(n,dep): l = n - m*(3-dep) u = n if (l < 0):l = 0 if (m < u):u = 9 return l,u+1 il,iu= loop(n,0) for i in range(il,iu): jl,ju = loop(n-i,1) for j in range(jl,ju): ij = i+j kl,ku = loop(n-ij,2) for k in range(kl,ku): c += 1 print(c)
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s552565780
p00008
Accepted
while True: try: n = eval(input()) if n > 36: print(0) else: count = 0 for a in range(0, 10): for b in range(0, 10): for c in range(0, 10): for d in range(0, 10): if a + b + c + d == n: count += 1 print(count) except EOFError: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s542545460
p00008
Accepted
import itertools while True: try: n = int(input()) ans = 0 for a in itertools.product(range(10), repeat=4): if n == sum(a): ans += 1 print(ans) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
s239306531
p00008
Accepted
import itertools while True: try:print([sum(a)for a in itertools.product(range(10),repeat=4)].count(int(input()))) except:break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>