Problem:


Problem A: Sum of Consecutive Integers

連続する整数の和

-->

あなたは数か月に渡る受験戦争を勝ち抜き，晴れてICPC大学に入学することができた．入学手続きの日，大学のキャンパス内では熱狂的なサークルの勧誘活動が行われており，あなたは大量のパンフレットを受け取って帰ってきた．部屋に戻ってきたあなたは受け取ったパンフレットの中から気になる一枚を見つけた．そのパンフレットは大学の広報部から渡されたものだった．

パンフレットには以下のような問題が記されていた．

和が N となるような，連続する2つ以上の正の整数の組み合わせは，何組存在するでしょうか？例えば， 9 は 2+3+4 と 4+5 の 2通りの組み合わせがあります．

この問題の答えが気になったあなたは，プログラムを書いてその答えを調べることにした．したがって，あなたの仕事は，入力として与えられる正の整数 N に対して，問題の答えを出力するプログラムを書くことである．

Input

入力はデータセットの並びである．各データセットはひとつの整数 N からなる一行である．ここで 1 ≤ N ≤ 1000 である．

入力の終りは，ひとつのゼロからなる一行で示される．

Output

出力は，入力の各データセットの表す正の整数に対する問題の答えを，入力データセットの順序通りに並べたものである．それ以外の文字が出力にあってはならない．

Sample Input

9
500
0

Output for the Sample Input

2
3



Sample input:
9
500
0


Sample output:
2
3

Submission status: Wrong Answer

Solution code:
while True:
    N = int(input())
    if N == 0:
        break
    ans = 0
    for i in range(N):
        for j in range(i, N):
            if (i + j) * (j - i + 1) // 2 == N:
                ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
results = []

while True:
    N = int(input())
    if N == 0:
        break
       
    tmp = [0 for _ in range(N+1)]
    res = 0
    
    for i in range(1, N+1):
        tmp[i] = tmp[i-1] + i
        
    for i in range(1, N):
        for j in range(i+2, N+1):
            if tmp[j] - tmp[i] == N:
                res += 1
                
    results.append(res)
            
for result in results:
    print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 0, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if N:
			print compute(int(N))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 0, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if int(N) > 0:
			print compute(int(N))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 0, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if int(N) > 0:
			print compute(int(N))
		else:
			print 0

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 1, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if int(N) > 0:
			print compute(int(N))
		else:
			print 0

Submission status: Wrong Answer

Solution code:
while True:
    n = input()
    if n==0:
        break
    ans = 0
    for i in xrange(n/2+1):
        su = 0
        c = i
        while su<n:
            su += c
            c += 1
        if su==n:
            ans += 1
    print ans

Submission status: Wrong Answer

Solution code:

while True:
	n = int(input())
	if n == 0:
		break
	count = 0
	for i in range(int((n+1)/2)):
		s = 0
		j = i
		while s < n:
			s += j
			j += 1
			if s == n:
				count += 1
	print(count)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

try:
	while True:
		n=int(raw_input())
		if n==0: break
		r=0
		i=1
		while 1:
			n-=i
			if n<0: break
			i+=1
			if n%i==0: r+=1
		print(r)
except EOFError:
	pass

Submission status: Wrong Answer

Solution code:
while 1:
    x=int(input())
    if x==0:
        break
    y=0
    for i in range(2,50):
        if x//i - i//2<0:
            break
        if i%2==0:
            if x/i-x//i==0.5:
                y+=1
        else:
            if x%i==0:
                y+=1
    print(y)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    while True:
        n = int(input())
        if n ==0:break
        nline = [i for i in range(n)]
        count = 0
        for i in range(n):
            for j in  range(i,n):
                if sum(nline[i:j]) > n:break
                if sum(nline[i:j]) == n:count +=1

        print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    while True:
        n = int(input())
        if n ==0:break
        count = 0
        for i in range(n):
            for j in  range(i+1,n):
                sum = (i+j)*(i+j-1)/2
                if  sum> n:break
                if sum == n:count +=1

        print(count)

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    ans = 0
    for i in range(n):
        s = i
        for j in range(i + 1, n):
            s += j
            if s == n:
                ans += 1
                break
            elif s > n:
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
a=0
while True:
  n=int(input())
  if n==0: break
  elif n%2!=0: a+=1
  for i in range(3,n//2,2):
    if n%i==0: a+=1
  print(a)

Submission status: Wrong Answer

Solution code:
import sys, os

n = int(raw_input())
if n == 0: sys.exit()

cnt = 0
for i in range(1, 1001):
    t = 0
    for j in range(i, 1001):
        t = t + j
        if n < t: break
        if n == t and i <> j:
            #print str(i) + "-" + str(j)
            cnt = cnt + 1

print cnt

Submission status: Wrong Answer

Solution code:
while 1:
    n = input();
    if not n:
        exit()
    ans = 0
    for i in range(n):
        m = 0
        b = False
        for j in range(i, n):
            m += j
            if m > n:
                b = False
                break
            if m == n:
                b = True
                break
        ans += b
    print ans

Submission status: Wrong Answer

Solution code:
while 1:
	n = input()
	if n == 0: break
	ans = 0
	for i in range(n/2-1):
		s = i
		for j in range(i+1,n/2):
			s += j
			if s >= n:
				if s == n:
					ans += 1
				break
	print ans

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0:
        break
    ans = 0
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if (i + j) * (j - i + 1) / 2 == N + 0.0:
                ans += 1
    print(ans)

Submission status: Accepted

Solution code:
results = []

while True:
    N = int(input())
    if N == 0:
        break
       
    tmp = [0 for _ in range(N+1)]
    res = 0
    
    for i in range(N+1):
        tmp[i] = tmp[i-1] + i
        
    for i in range(N-1):
        for j in range(i+2, N+1):
            if tmp[j] - tmp[i] == N:
                res += 1
                
    results.append(res)
            
for result in results:
    print(result)

Submission status: Accepted

Solution code:
items = []
while True:
    item = int(input())
    if item == 0:
        break
    else:
        items.append(item)

for item in items:
    cnt = 0
    tmp = list(range(1, item+1))
    for i in range(2, item+1):
        for j in range(item - i):
            win = tmp[j:j+i]
            win = sum(win)
            if win == item:
                cnt += 1
                break
            elif win > item:
                break
    print(cnt)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

while True:
    N = int(readline())
    if N == 0: break
    lo = 1
    hi = 2
    s = lo + hi
    cnt = 0
    while lo < N:
        if s < N:
            hi += 1
            s += hi
        elif s > N:
            s -= lo
            lo += 1
        else:
            cnt += 1
            hi += 1
            s += hi
    print(cnt)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0:
        exit()
    cnt = 0
    i = 2
    while i*(i+1) <= n*2:
        a =int(n/i-(i-1)/2) 
        if a*i + (i-1)*i/2 == n:
            cnt += 1
        i += 1
    print(cnt)

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            divisors = set()
            for i in range(1, int(math.sqrt(n))+1):
                if n % i == 0:
                    f = n / i
                    if i != 1 and i % 2 == 1:
                        divisors.add(i)
                    if f != 1 and f % 2 == 1:
                        divisors.add(f)
            # print divisors
            print len(divisors)
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    N = int(input())
    if N==0:
        break
    count = 0
    for i in range(1,N//2+2):
        for j in range(i+1,N//2+2):
            hoge = (j-i+1)*(2*i+j-i)//2
            if hoge  == N:
                count += 1
            elif hoge > N:
                break
    print(count)

Submission status: Accepted

Solution code:
while (1):
	n = int(raw_input())
	way = 0
	if n == 0:	
		break
	for d in range(2, n):
		if d % 2 == 0 :
			if  (n % d) * 2 == d and n / d >= d / 2:
				way += 1
		else :
			if n % d == 0 and n / d > (d - 1) / 2:
				way += 1
	print way

Submission status: Accepted

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

n = int(raw_input())

while n != 0:
    cnt = 0
    for i in range(1, n/2+1):
        sum = 0
        for j in range(i, n):
            sum += j
            if sum > n:
                break
            elif sum == n:
                cnt += 1
                break
    print cnt
    n = int(raw_input())

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 1, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if int(N) > 0:
			print compute(int(N))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    count = n
    for i in range(1, n):
        a = 0
        for j in range (i, n):
            a += j
            if a == n:
                ans += 1
                break
            if a > n:
                break
#    for i in range(2, n):
#        a = int(n / i)
#        print("a=", a)
#        b = a
#        for j in range(0,i-1):
#            a += 1
#            b += a
#        print("b=", b)
#        if a == b:
#            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    count = n
    for i in range(1, n):
        a = 0
        for j in range (i, n):
            a += j
            if a == n:
                ans += 1
                break
            if a > n:
                break
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n==0:
        break
    ans = 0
    for i in xrange(1, n/2+1):
        su = 0
        c = i
        while su<n:
            su += c
            c += 1
        if su==n:
            ans += 1
    print ans

Submission status: Accepted

Solution code:
import math
while 1:
    n = int(raw_input())
    if not n:
        break
    ans = 0
    for p in xrange(1, int(math.sqrt(2*n))+1):
        if 2*n % p ==0:
            q = 2*n / p
            if p>1 and (p+q)%2:
                ans += 1
    print ans

Submission status: Accepted

Solution code:
while 1:
    n = int(raw_input())
    if not n:
        break
    ans = 0
    p = 2
    while p**2 <= 2*n:
        if not 2*n % p:
            if (p + 2*n/p) % 2:
                ans += 1
        p += 1
    print ans

Submission status: Accepted

Solution code:

while True:
	n = int(input())
	if n == 0:
		break
	count = 0
	for i in range(1, int((n+1)/2)):
		s = 0
		j = i
		while s < n:
			s += j
			j += 1
			if s == n:
				count += 1
	print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

try:
	while True:
		n=int(raw_input())
		if n==0: break
		r=0
		i=1
		while 1:
			n-=i
			if n<i: break
			i+=1
			if n%i==0: r+=1
		print(r)
except EOFError:
	pass

Submission status: Accepted

Solution code:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

try:
	while True:
		n=int(raw_input())
		if n==0: break
		r=0
		i=1
		while 1:
			n-=i
			if n<=i: break
			i+=1
			if n%i==0: r+=1
		print(r)
except EOFError:
	pass

Submission status: Accepted

Solution code:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

try:
	while True:
		n=int(raw_input())
		if n==0: break
		r=0
		i=1
		while 1:
			n-=i
			i+=1
			if n<i: break
			if n%i==0: r+=1
		print(r)
except EOFError:
	pass

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())

    if n == 0:
        break

    cnt = 0

    for i in range(1, n):
        temp = 0
        for j in range(i, n):
            temp += j
            if temp == n:
                cnt += 1
            elif temp > n:
                break
    print cnt

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def count_combinations(n):
    answer = 0
    for i in range(1, n // 2 + 1):
        current_sum = i
        for j in range(i + 1, n // 2 + 2):
            current_sum += j
            if current_sum == n:
                answer += 1
                break
            elif current_sum > n:
                break
            else:
                continue
    return answer


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        else:
            print(count_combinations(n))

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

while 1:
    x=int(input())
    if x==0:
        break
    y=0
    for i in range(2,50):
        if x/i - i/2<0.1:
            break
        if i%2==0:
            if x/i-x//i==0.5:
                y+=1
        else:
            if x%i==0:
                y+=1
    print(y)

Submission status: Accepted

Solution code:
while True:
  N = int(raw_input())
  if N==0: break
  n = 2
  count = 0
  while n <= N:
    if n % 2 == 0:
      if N/n*n != N and N*2/n*n == N*2:
        if N/n >= n/2:
          count += 1
    else:
      if N/n*n == N:
        if N/n > n/2:
          count += 1
    n += 1
  print count

Submission status: Accepted

Solution code:
#coding: utf-8

while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        a = 0
        for i in range(1,n+1):
            i = i*1.0
            if i*(i+1)/2 > n:
                break
            for k in range(1,n+1):
                if i*(2*k+i-1)/2 > n:
                    break
                elif i*(2*k+i-1)/2 == n:
                    a = a + 1
                else:
                    continue
        print a - 1

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0: break
    cnt,a,b = 0,1,2
    while True:
        if (n-a)>=b and (n-a)%b==0: cnt+=1
        a += b
        b += 1
        if n-a<b: break
    print(cnt)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())*2
    if n==0:break
    i,c=2,0
    while i*i<n:
        if not(n%i) and n//i%2!=i&1:c+=1
        i+=1
    print(c)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())*2
    if n==0:break
    i,c=2,0
    while i*i<n:
        if not(n%i) and n//i&1!=i&1:c+=1
        i+=1
    print(c)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())*2
    if n==0:break
    i,c=2,0
    while i*i<n:
        if not(n%i) and n//i%2!=i%2:c+=1
        i+=1
    print(c)

Submission status: Accepted

Solution code:
def SCI(i):
    i -= 1
    x = i * (i + 1) / 2
    return x


while 1:
    x = int(input())
    if x == 0:
        break
    ans = 0
    for i in range(2,x/2+2):
        if x-SCI(i) <= 0:
            break
        elif (x-SCI(i))%i == 0:
            ans += 1
    print ans

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    num = 2
    cnt = 0
    while True:
        ini = num * (num + 1) // 2
        if n < ini:
            break
        while ini <= n:
            if ini == n:
                cnt += 1
                break
            ini += num

        num += 1

    print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8

if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break
        id = 1
        sm = 0
        res = 0
        while True:
            sm += id
            if sm >= n:
                break
            if (n - sm)%(id+1) == 0:
                if (n - sm)//(id+1) > 0:
                    res += 1
            id += 1
        print(res)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    while True:
        n = int(input())
        if n ==0:break
        nline = [i for i in range(1,n+1)]
        count = 0
        for i in range(n):
            for j in  range(i+1,n):
                if sum(nline[i:j]) > n:break
                if sum(nline[i:j]) == n:count +=1

        print(count)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    while True:
        n = int(input())
        if n ==0:break
        count = 0
        for i in range(1,n):
            for j in range(i+1,n):
                sum = (i+j)*(j-i+1)/2
                if sum> n:break
                if sum == n:count +=1

        print(count)

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0: break
    ans = 0
    cum = 1
    for n in range(2,N):
        cum += n
        if cum > N: break
        if (N - cum) % n == 0: ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if(N==0):
        break
    ans=0
    for i in range((N//2)+1,0,-1):
        SUM=i
        k=i-1
        while SUM<=N and k>0:
            SUM+=k
            if SUM==N:
                ans+=1
            k-=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    N = int(raw_input())

    if N == 0:
        break

    ans, t = 0, 0

    for i in range(1, N):
        t = i
        for j in range(i+1, N):
            t += j
            if t == N:
                ans += 1
                break
            elif t > N:
                break

    print ans

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    ans = 0
    for i in range(1, n + 1):
        s = i
        for j in range(i + 1, n + 1):
            s += j
            if s == n:
                ans += 1
                break
            elif s > n:
                break
    print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    while True:
        n = I()
        if n == 0:
            break
        r = 0
        for i in range(1,n):
            t = i
            while t < n:
                i += 1
                t += i
            if t == n:
                r += 1
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0 : break
    ans = 0
    for i in range(1,999):
        for j in range(i+1,1000):
            if (i+j)*(j-i+1)//2 == n:
                ans+=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    c = 0
    for i in range(2, 1001//2):
        for a in range(1, 1001//2):
            if i*a+(0.5*(i-1)*i) == n:
                c += 1
    print(c)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if not n:break    
    t=0
    cnt=0
    for i in range(2,n+1):
        o=n//i
        t+=(i-1) 
        p=n-(i*o-t)
        if o+p//i+1-i<1:break
        if p%i==0:cnt+=1
    print(cnt)

Submission status: Accepted

Solution code:
import sys
import collections


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    
    divisible = 0
    for i in xrange(3, n + 1, 2):
        if n % i == 0:
            divisible += 1
    print divisible

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    cnt=0
    for i in range(1,n):
        temp=0
        for j in range(i,n):
            temp+=j
            if temp==n:
                cnt+=1
            elif temp>n:
                break
    print cnt

Submission status: Accepted

Solution code:
S = 0; l = []; a = [0]*1001
for i in xrange(1001):
    S += i
    l.append(S)
for i in xrange(1001):
    for j in xrange(i-2,-1,-1):
        if l[i]-l[j]>1000: break
        a[l[i]-l[j]]+=1
while 1:
    n = input()
    if n==0: break
    print a[n]

Submission status: Accepted

Solution code:
while 1:
    n = input();
    if not n:
        exit()
    ans = 0
    for i in range(1, n):
        m = 0
        for j in range(i, n):
            m += j
            if m > n:
                break
            if m == n:
                ans += 1
    print ans

Submission status: Accepted

Solution code:
while 1:
	n = input()
	if n == 0: break
	ans = 0
	for i in range(1,n/2+1): 
		s = i
		for j in range(i+1,n/2+2):
			s += j
			if s >= n:
				if s == n:
					ans += 1
				break
	print ans

Submission status: Accepted

Solution code:
while True:
    num = int(input())
    if num == 0: break
    ans = 0
    for i in range(1,num+1):
        for j in range(i+1,num+1):
            i += j
            if i == num: 
                ans += 1 
                break
            elif i>num: break
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    tori=0
    for i in range(1,n):
        sum=0
        for j in range(i,n):
            sum+=j
            if sum==n:
                tori+=1
            if sum>n:
                break
    print(tori)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if(n==0):
        break
    
    a=[]
    
    for i in range(1, n):
        a.append(i)
    k=0
    
    for i in range(n-2):
        for j in range(i+2, n):
            if(sum(a[i:j])==n):
                k+=1
            if(sum(a[i:j])>n):
                break
    print(k)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    for i in range(1,n):
        b = 0
        for j in range(i,n):
            b += j
            if b == n:
                a += 1
            if b > n:
                break
    print(a)

Submission status: Accepted

Solution code:
while True:
    x=int(input())
    if x==0:
        break
    y=0
    for i in range(2,50):
        if x/i - i/2<0.1:
            break
        if i%2==0:
            if x/i-x//i==0.5:
                y+=1
        else:
            if x%i==0:
                y+=1
    print(y)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    a = 0
    for i in range(1,n):
        b = 0
        for j in range(i,n):
            b += j
            if b >= n:
                break
        if b == n:
            a += 1
    print(a)

Submission status: Accepted

Solution code:
while True:
    C=0
    n=int(input())
    if n==0:
        break
    for i in range(n-1):
        A=i
        B=0
        while True:
            A=A+1
            B=B+A
            if B==n:
                C=C+1
            if B>=n:
                break
    print(C)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    
    if n == 0:
        break
    
    ans = []
    cnt = 0
    for i in range(1, n//2+2):
        p = i
        for j in range(i+1, n//2+2):
            p += j
            if p == n:
                cnt += 1
            elif p > n:
                break
    ans.append(cnt)
    print(*ans)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    ans=0
    for i in range (1,n+1):
        s=i
        for j in range(i+1,n+1):
            s+=j
            if s==n:
                ans+=1
                break
            elif s>n:
                break
    print(ans)

Submission status: Accepted

Solution code:
while True:
   N = int(input())
   if N == 0:
      break
   s = list(range(1, (N+1)//2+1))
   c = 0
   for i in range(len(s)):
      for j in range(len(s)):
         if s[i] + 1 <= s[j]:
            if N == sum(range(s[i],s[j]+1)):
               c += 1
   print(c)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    count = n
    for i in range(1, n):
        a = 0
        for j in range (i, n):
            a += j
            if a == n:
                ans += 1
                break
            if a > n:
                break
    print(ans)

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N==0:
        break
    a = 0
    for i in range(1,N):
        s = 0
        for j in range(i,N+1):
            s += j
            if s == N:
                a += 1
                
            elif s > N:
                break
            
    print(a)

Submission status: Accepted

Solution code:
#00:12
import math

def sum_of_num(target,num):
    return (((2*target)/num)-num+1)/2


while True:
    target_num = int(input())
    if target_num ==0:
        break
    
    count = 0
    for i in range(2,int(target_num)):
        n = sum_of_num(target_num,i)
        if n.is_integer() and n >0:
            count = count + 1
    
    print(count)

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if N==0:
        break
    l=list(range(1,N+1))
    x=0
    for i in range(3,N+1):
        SUM=sum(l[0:i])
        if SUM==N:
            x+=1
        for j in range(i-2):
            SUM=SUM-l[j]
            if SUM==N:
                x+=1
    if N==3:
        print('1')
    else:
        print(x)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        c=0
        for i in range(1,n+1):
            S=i
            for j in range(i+1,n+1):
                S+=j
                if S==n:
                    c+=1
                    break
                if S>n:
                    break
        print(c)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
   N = int(input())
   if N == 0: break
   
   c = 0
   for i in range(1, N // 2 + 2):
      sum = 0
      for j in range(i, N // 2 + 2):
         sum += j
         if sum == N and j != N:
            c += 1
            break
   print(c)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    ans=0
    s=1
    e=1
    sam=0
    while s<=n:
        if sam<n:
            sam+=e
            e+=1
        elif sam==n:
            ans+=1
            s+=1
            sam=0
            e=s
        else:
            s+=1
            sam=0
            e=s
    print(ans-1)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    
    if n == 0:
        break
    
    a=0
    for i in range(1,n):
        b = i
        
        for j in range(i+1,n):
            b += j
            
            if b==n:
                a+=1
                break
            elif b>n:
                break
            
    print(a)

Submission status: Accepted

Solution code:
import math

while True:
    n = int(input())
    if n == 0:break
    c = 0
    for x in reversed(range(1,math.ceil(n/2)+1)):
        sumx = 0
        add_c = 0
        for y in reversed(range(1,x+1)):
            sumx += y
            add_c += 1
            if sumx >= n:
                break
        if sumx == n and add_c > 1:
            c += 1
    print(c)

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    count = 0
    for i in range(1, n) :
        s = 0
        for j in range(i, n) :
            s += j
            if s == n :
                count += 1
            if s > n :
                break
    print(count)

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N==0:
        break
    
    Nlist = list(range(1,N))
    count = 0
    while True:
        for i in range(1,1001,1):
            if i>=N/2:
                break
            sum = 0
            j = i
            while True:
                sum += j
                j += 1
                if sum>=N:
                    if sum==N:
                        count += 1
                    break
        break
        
    print(count)
    continue

Submission status: Accepted

Solution code:
N = [i for i in range(1, 1001)]

while True :
    n = int(input())
    
    if n == 0 :
        break
    
    else :
        cnt = 0
        
        for i in range(1, (n // 2) + 2) :
            s = N[i - 1]
            l = 1
            
            for j in range(i + 1, (n // 2) + 3) :
                if s < n :
                    s += N[j - 1]
                    l += 1
                    
                elif s == n and l > 1:
                    cnt += 1
                    break
                else :
                    break
                
        print(cnt)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    p=0
    if n==0:
        break
    else:
        s=[i for i in range(1,n)]
        for i in range(2,n):
            for j in range(0,n-i+1):
                ss=sum(s[j:i:])
                if ss==n:
                    p+=1
    print(p)