Problem:


Structured Programming

In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.

Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.

Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout n is given in a line.

Output

Print the output result of the above program for given integer n.

Constraints

3 ≤ n ≤ 10000

Sample Input

30

Sample Output

 3 6 9 12 13 15 18 21 23 24 27 30

  Put a single space character before each element.



Sample input:
30


Sample output:
 3 6 9 12 13 15 18 21 23 24 27 30

Submission status: Accepted

Solution code:
n=int(input())
a=0
for i in range(1,n+1):
    x=int(i)
    if  x%3==0:
        a=1

    else:
        while x >= 0 and i >=10:
            if x%10==3:
                a=1
                break
            elif x>10:
                x=x//10
            else:
                break
    if a:
        print(f" {i}",end="")
        a=0
print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1):
    if (i%3 == 0) or (i%10 == 3) or ("3" in str(i)):
        print(" " + str(i), end="")
print("")

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if i%3==0 or (str(3) in set(list(str(i))) ) :
        print(" {}".format(i),end="")
print("")

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n+1):
  if i % 3 == 0:
    print(" " + str(i), end ="")
  else:
    x = i
    while(x):
      if x % 10 == 3:
        print(" " + str(i), end ="")
        break
      x //= 10
print()

Submission status: Accepted

Solution code:
N =int(input())
lst =[]
for n in range(1,N+1):
    if n%3 ==0 or '3' in str(n):
        lst.append(n)
        
print(" "+" ".join([str(x) for x in lst]))

Submission status: Accepted

Solution code:
def calc(n):
    for i in range(1, n+1):
        if i % 3 == 0:
            print("", i, end='')
            continue

        x = i

        while x > 0:
            if x % 10 == 3:
                print("", i, end='')
                break

            x = x // 10

    print()

calc(int(input()))

Submission status: Accepted

Solution code:
print('',*[x for x in range(3,int(input())+1) if x%3==0 or '3' in str(x)])

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        print(" "+str(i),end = "")
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(" "+str(i),end = "")
                break
            x //= 10
print()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    x = 0

    for i in range(1, n + 1):

        if i % 3 == 0:
            print(f" {i}", end="")
        else:
            x = i
            while (x):
                if x % 10 == 3:
                    print(f" {i}", end="")
                    break
                x //= 10

    print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1):
    if i % 3 == 0:
        print(" " + str(i), end="")
    else:
        x = i
        while(x):
            if x % 10 == 3:
                print(" " + str(i), end="")
                break
            x //= 10

print()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
x = int(input())
figure = 3

while figure <= x:
    if figure % 3 == 0 or '3' in str(figure):
        print(' ',end = '')
        print(figure, end = '')
    figure += 1
print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end='')
        continue
    x = i
    while x:
        if x % 10 == 3:
            print(" {}".format(i), end='')
            break
        x //= 10
print()

Submission status: Accepted

Solution code:
n=int(input())

for i in range(1,n+1):
    x=i
    int(x)
    if x%3==0 :
        print(" %d" % i, end="")
    else:
        while x:
            if int(x)%10==3:
                print(" %d" % i, end="")
                break
            else :
                x/=10
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:  #3の倍数か
        print(" " + str(i), end="")
    else:
        x = i
        while x > 0:
            if x % 10 == 3:  #3が付く数か
                print(" " + str(i), end="")
                break
            x //= 10
print()

Submission status: Accepted

Solution code:
for i in range(1, int(input()) + 1):
    x = i
    if not x % 3:
        print(f' {i}', end='')
        continue
    
    while x:
        if x % 10 == 3:
            print(f' {i}', end='')
            break
        x //= 10
print()

Submission status: Accepted

Solution code:
for i in range(1,int(input())+1):
  x = i
  if x%3==0:
    print (" ", end="")
    print (i, end="")
    continue
  while True:
    if x%10==3:
      print (" ", end="")
      print (i, end="")
      break
    x = int(x/10)
    if not x:
      break
print ()

Submission status: Accepted

Solution code:
for i in range(1,int(input())+1):
    s=str(i)
    if i%3==0 or i%10==3 or '3' in s:
        print(f" {i}",end='')
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    i=i+1
    x=i
    if (x%3==0):
        print(" {}".format(i),end="")
    else:
        while True:
            if (x%10==3):
                print(" {}".format(i), end="")
                break
            x=x//10
            if (x==0):
                break
print()

Submission status: Accepted

Solution code:
def has3(x):
    while x>0:
        if x%10==3:
            return True
        x = x//10
    return False

n = int(input())
for i in range(1, n+1):
    if i%3==0 or has3(i):
        print(f" {i}", end="")
print()

Submission status: Accepted

Solution code:
a=int(input())
for i in range(1,a+1):
    if i%3 ==0:
        print(" %d" %i, end="")
    else:
        x=i
        while (x):
            if x % 10 == 3:
                print(" %d"%i, end="")
                break
            else:
                x//=10
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0:
        print("",i,end="")
    else:
        t = i
        while t:
            if t % 10 == 3:
                print("",i,end="")
                break
            t //= 10
print()

Submission status: Accepted

Solution code:
n = int(input())

def check_num(x):
	if x % 3 == 0:
		return True

def include3(x):
	while True:
		if x ==0:
			break
		if x%10==3:
			return True
		x //= 10

for i in range(1,n+1):
#	check_num(i)
	if include3(i) or check_num(i):
		print(f' {i}',end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n + 1):
    if(i % 3 == 0 or ("3" in str(i))):
        # print(f" {i}", end="")
        print(" {}".format(i), end = '')
print()

Submission status: Accepted

Solution code:
n=int(input())
i=1
L=[]
while i<=n:
    x=i
    if x%3==0:
        L.append(x)
    else:
        while x>0:
            if x%10==3:
                L.append(i)
                break
            x=int(x/10)
    i+=1
l=len(L)

for i in range(l):
    if i!=l-1:
        print(' {}'.format(L[i]),end='')
    else:
        print(' {}'.format(L[i]))

Submission status: Accepted

Solution code:
n = int(input())

for i in range(n + 1):
    if i != 0 and (i % 3 == 0 or '3' in str(i)):
            print(" " + str(i), end="")
print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n + 1):

    if (((i % 3) == 0) or
        (("3" in str(i)))):
        print(" " + str(i), end="")

print()

Submission status: Accepted

Solution code:
n = int(input())
a = ''
for i in range(1,n+1):
    x = i
    if x % 3 == 0:
        a = a + ' ' + str(i)
    elif x % 10 == 3:
        a = a + ' ' + str(i)
    else:
        x = x // 10
        while True:
            if x == 0:
                break
            else:
                if x % 10 == 3:
                    a = a + ' ' + str(i)
                    break
                x = x // 10

print(a)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(3,n+1):
  if i%3==0 or '3' in str(i):
    print( " ",i,sep='',end='')
print("")

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0 or str(i).find("3") != -1:
        print(" {}".format(i), end ="")
print()

Submission status: Accepted

Solution code:
n = int(input())
result = []
for x in range(1, n+1):
    if x % 3 == 0:
        result.append(x)
        continue
    i = x
    while i:
        i, r = divmod(i, 10)
        if r == 3:
            result.append(x)
            break
print(' '.join(['']+ [str(i) for i in result]))

Submission status: Accepted

Solution code:
n =int(input())


for i in range(3,n+1):
  x=i
  if x%3==0:
    print("",i,end="")
  elif x%10==3:
    print("",i,end="")
  else:
    while x:
      if x % 10 == 3:
        print("",i,end="")
        break
      else:
        x = x // 10
print()

Submission status: Accepted

Solution code:
s = int(input())

for i in range(1,s+1):
  #1の位
  a = i%10
  #10の位
  b = ((i-a)//10)%10
  #100の位
  c = ((i-(a+b*10))//100)%10
  #1000の位
  d = ((i-(a+b*10+c*100))//1000)%10
  #10000の位
  e = ((i-(a+b*10+c*100+d*1000))//10000)%10

  if a==3 or b==3 or c==3 or d==3 or e==3 or i%3==0:
      print(" %d"%i, end = "")
      
  a = 0
  b = 0
  c = 0
  d = 0
  e = 0
  
print()

Submission status: Accepted

Solution code:
n=input()
n=int(n)
i = int (1)
while True:
  if (i>n):
    break
  x=int(i)
  if (x%3 == 0):
    print ("",i,end="")
  elif(x%10 == 3):
    print ("",i,end="")
  else:
    while True:
      if(x==0):
        break
      x=x//10
      if(x%10 == 3):
        print ("",i,end="")
        break
  i=i+1
print ("")

Submission status: Accepted

Solution code:
n = input()
x = int(n)
for i in range(3,x+1) :
 if i%3 == 0 or '3' in str(i) :
   print('',i,end='')
print()

Submission status: Accepted

Solution code:
def call(num):
  ans=[]
  for i in range(1,n+1):
    if i%3==0:
      ans.append(i)
    else:
      tmp=i
      flag=False
      while tmp>0:
        if tmp%10==3:
          flag=True
        tmp=tmp//10
      if flag:
        ans.append(i)
  print(' '+' '.join(map(str,ans)))

n=int(input())
call(n)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
  if i % 3 == 0:
    print("", i, end = "")
  else:
      x = i
      while(x):
        if(x % 10 == 3):
          print("", i, end = "")
          break
        x //= 10
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3, n + 1) :
    if(i % 3 == 0 or "3" in str(i)) :
        print(" ", i, sep = "", end = "")
        i += 1
    else :
        pass
print()

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,n+1):
    check = []
    if i%3 == 0:
        l.append(str(i))
    for j in str(i):
        if j == "3" and (not i%3 == 0):
            l.append(str(i))
            break
str = ' '.join(l)

print(" "+str)

Submission status: Accepted

Solution code:
N=int(input())

def call(n):
	lstAns=list()
	for x in range(1,n+1):
		if x % 3 == 0:
			lstAns.append(x)
			continue
		y = x
		while 0 < y:
			if y % 10 == 3:
				lstAns.append(x)
				break
			else:
				y //= 10

	return lstAns

ans = call(N)

ans = " ".join(map(str,ans))
if 0 < len(ans):
	ans = " " + ans

print(ans)

Submission status: Accepted

Solution code:
inVal = int(input())
outLen = ""
for i in range(1, inVal + 1):
    if i % 3 == 0:
        outLen = outLen + " " + str(i)
    else:
        x = i
        while (x):
            if x % 10 == 3:
                outLen = outLen + " " + str(i)
                break
            x = x // 10
print(outLen)

Submission status: Accepted

Solution code:
n = int(input())
i = n
for i in range(1,n+1):
    if i % 3 == 0:
        print(' {}'.format(i),end = '')
    
    else:
        st = str(i)
        for j in range(len(st)):
            if(st[j] == '3'):
                print(' {}'.format(i),end = '')
                break
print()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n = int(input())
	res = ""
	for i in range(1,n+1):
		x = i
		if i % 3 == 0:
			res=res+" "+str(i)
			x = 0
		elif i % 10 == 3:
			res=res+" "+str(i)
			x = 0
		while x != 0:
			x = x // 10
			if x % 10 == 3:
				res=res+" "+str(i)
				x = 0
				
	print(res)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,n+1):
  if i % 3 ==0 or str(i).find("3") != -1:
    print(" {}".format(i),end = "")
print()

Submission status: Accepted

Solution code:
N = int(input())
x = 0

for i in range(1, N+1):
    if i%3==0:
        print(' %d'%i, end="")
    else:
        x = i
        while (x):
            if x%10==3:
                print(" %d"%i, end="")
                break
            x //= 10
print()

Submission status: Accepted

Solution code:
ans = []
num = int(input())
for i in range(1,num+1):
	if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
		ans.append(" " + str(i))
print(*ans,sep="")

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1):
    if i%3 == 0:
        print('', i, end='')
    elif str(i).count('3') > 0:
        print('', i, end='')

print('\r')

Submission status: Accepted

Solution code:
l=[]
num=int(input())
for i in range(num+1):
	if i%3==0 and i!=0:
		l.append(i)
	elif '3' in str(i):
		l.append(i)

ans=' '.join(list(map(str,l)))
print(' '+ans)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3, n + 1):
	if i % 3 == 0 or str(i).find("3") != -1:
		print(" {}".format(i), end = '')
print()

Submission status: Accepted

Solution code:
i = 1
n = int(input())
while i <= n:
    if i % 3 == 0 or '3' in str(i):
        print(" ", end="")
        print(i, end="")
    i += 1
print()

Submission status: Accepted

Solution code:
n = int(input())
nums = []
for i in range(1, n+1):
    if i%3 == 0:
        nums.append(i)
    elif '3' in list(str(i)):
        nums.append(i)
m = len(nums)
print('', end = ' ')
for i in range(m-1): 
    print(nums[i], end = ' ')
print(nums[m-1])

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n+1):
    if i%3 == 0 :
        print(' {}'.format(i),end='')

    elif '3' in str(i):
        print(' {}'.format(i),end='')
print()

Submission status: Accepted

Solution code:
#! python3
# structuredProgramming.py - 構造化プログラミングの練習

def checkNum(n):
  if n % 3 == 0:
    return True
  elif include3(n):
    return True
  else :
    k = n
    while k >= 30:
      k = int(k / 10)
      if include3(k):
        return True
  
def include3(n):
  if n % 10 == 3:
    return True
  else :
    return False

input_int = int(input())

numbers = []
for i in range(1, input_int+1):
  if checkNum(i):
    numbers.append(i)

str_numbers = list(map(str, numbers))
print(' '+' '.join(str_numbers))

Submission status: Accepted

Solution code:
n = int(input())
i = 1
while 1:
    x = i
    if x % 3 ==0:
        print(' ', i, sep='', end='')
    else:
        while x:
            if x % 10 == 3:
                print(' ', i, sep='', end='')
                break
            x //= 10
    if i >= n:
        break
    else:
        i += 1
print()

Submission status: Accepted

Solution code:
n=int(input())
ans=""
for i in range(1,n+1):
    if i%3==0:
        ans+=" "+str(i)
        continue
    x=i
    while(x):
        if x%10==3:
            ans+=" "+str(i)
            break            
        x//=10
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,n+1):
    if i%3==0 or "3" in str(i):
        l.append(" "+str(i))
print("".join(l))

Submission status: Accepted

Solution code:
x = int(input())
for i in range(1,x+1):
    if i % 3 == 0:
        print(' ' + str(i), end = "")
    else:
        n = i
        while(n):
            if n % 10 == 3:
                print(' ' + str(i), end = "")
                break
            n = n // 10
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3, n + 1):
    x = i
    if x % 3 == 0:
        print(" " + str(i), end="")
        continue
    while x > 0:
        if x % 10 == 3:
            print(" " + str(i), end="")
            break
        x //= 10
print("")

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
    x = i
    if x % 3 == 0:
        print(" " + str(i), end="")
    else:
        while x > 0:
            if x % 10 == 3:
                print(" " + str(i), end="")
                break
            x = x // 10
print()

Submission status: Accepted

Solution code:
# ITP1_5_D
# 構造化プログラミング

n = int(input())
for i in range(1, n+1):
	x = i
	if x % 3 == 0:
		print(" " + str(i), end = "")
	else:
		while x:
			if x % 10 == 3:
				print(" " + str(i), end = "")
				break
			x //= 10
print()

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for i in range(3,n+1):
    if i % 3 == 0 or "3" in str(i):
        d.append(i)
print(' ',end="")
print(*d)

Submission status: Accepted

Solution code:
n = int(input())
li = []

for i in range(1,n+1):
    if (i%3 == 0) or (i%10 ==3) or(int(i/10)%10 ==3) or(int(i/100)%10 ==3)or(int(i/1000)%10 ==3):
        print(" "+str(i),end="")

print("")

Submission status: Accepted

Solution code:
i = int(input())

for i in range(i):
    i = i+1
    a = True

    if i%3 == 0:
        print(' ', end = '')
        print(i, end = '')
    else:
        x = i
        while a:
            if x%10 == 3:
                print(' ', end = '')
                print(i, end = '')
                break
            x //= 10
            if x == 0:
                a = False

print()

Submission status: Accepted

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


def call(n):
  for i in range(1,n+1):
    if i % 3 == 0:
      print(" " + str(i), end="")
    else:
      x = i
      while(x > 0):
        if x % 10 == 3:
          print(" " + str(i), end="")
          break
        else:
          x //= 10
  print()


N = int(input())
call(N)

Submission status: Accepted

Solution code:
N=int(input())
i=1
while i<=N:
    if(i%3==0 or str(i).find("3")!=-1):
        print(' {}'.format(i),end='')
    i+=1
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
	if i % 3 == 0 or '3' in str(i):
		print(" {}".format(i), end = '')
print()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1):
    if i%3 == 0 or '3' in str(i):
        print(' %d'%i, end='')
print()

Submission status: Accepted

Solution code:
a = []
N = int(input())
for i in range(1, N+1):
    if i % 3 == 0 or "3" in str(i):
        a.append(i)
print(" ", end="")
print(*a)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
	if i%3==0:
		print(" " + str(i),end="")
	else:
		x = i
		while (x):
			if x%10==3:  
				print(" " + str(i),end="")
				break
			x//=10
print()

Submission status: Accepted

Solution code:
a = int(input())
n = 1
while True:
    if n > a:
        break
    if n % 3 == 0:
        print(" {}".format(n),end="")
    else:
        m = n
        while m >= 3:
            if m % 10 == 3:
                print(" {}".format(n),end="")
                break
            else:
                m = m // 10
    n += 1
print()

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1, n+1):
    if i%3 ==0 or "3" in str(i):print(f" {i}",end="")
print()

Submission status: Accepted

Solution code:
n =int(input())
for i in range(1,n + 1):
        s = i
        if i % 3 == 0:
                print(" %d" % i,end = "")
        elif i / 10 != 0:
                for k in range(5):
                        if s % 10 == 3:
                                print( " %d"% i ,end = "")
                                break
                        elif s == 0:
                                break
                        s //= 10
print('')

Submission status: Accepted

Solution code:
n = int(input())
output = [""]

for i in range(1, n + 1):
    if i % 3 == 0:
        output.append(i)
    elif i % 10 == 3:
        output.append(i)
    elif str(3) in str(i):
        output.append(i)

print(' '.join(map(str, output)))

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,n+1):
    if i%3==0 or str(i).find("3")!=-1:
        print(" {}".format(i),end='')
print()

Submission status: Accepted

Solution code:
# coding: utf-8
def call(n):
    for i in range(1, n+1):
        x = i
        if x % 3 == 0:
            print(" " + str(i),end="")
            continue
        while x != 0:
            if x % 10 ==3:
                print(" " + str(i),end="")
                break
            x = x // 10
    print()
            
num = int(input())
call(num)

Submission status: Accepted

Solution code:
i = 1
rs = []
n = int(input())

while i <= n:
    x = i
    if x % 3 == 0:
        rs.append(i)
    else:
        while x:
            if x % 10 == 3:
                rs.append(i)
                break
            x //= 10

    i += 1

print(' ' + ' '.join(map(str, rs)))

Submission status: Accepted

Solution code:
n = int(input())
for x in range(1, n + 1):
    i = x
    if i % 3 == 0:
        print(' {}'.format(x), end = '')
    else:
        while i >= 1:
            if i % 10 == 3:
                print(' {}'.format(x), end = '')
                break
            i = i // 10
print('')

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if i%3 == 0 or i%10 ==3 or (i//10)%10 ==3 or (i//100)%10 ==3 or (i//1000)%10 ==3 :
        print(' '+str(i),end = '')
print()

Submission status: Accepted

Solution code:
N = int(input())
res = []
for i in range(1, N+1):
    if '3' in str(i) or i%3 == 0:
        res.append(i)

i = 0
print(" ", end="")
for r in res:
    print(r, end="")
    if i == len(res)-1:
        #pass
         print('\n', end="")
    else:
        print(" ", end="")

    i += 1

Submission status: Accepted

Solution code:
maxNum = int(input())
for i in range(3, maxNum + 1):
    if i % 3 == 0 or str(i).find("3") != -1:
        print("", i, end = "")
print()

Submission status: Accepted

Solution code:
n = int(input())

list = []
for x in range(3, n + 1):
    if x % 3 == 0:
        list.append(x)
    else:
        y = x
        while(y > 0):
            if(y % 10 == 3):
                list.append(x)
                break
            y //= 10

ans = ""
for x in list:
    ans += " " + str(x)
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = ['']
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            if i not in ans:
                ans.append(i)
        else:
            while x > 0:
                if x % 10 == 3:
                    if i not in ans:
                        ans.append(i)
                x //= 10
    print(' '.join(map(str, ans)))


main()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
    if "3" in str(i) or i % 3 == 0:
        print(" %i" % i, end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n + 1):
	if i % 3 == 0:
		print(' %d' % i, end="")
	else:
		j = i
		while j > 0:
			if j % 10 == 3:
				print(' %d' % i, end="")
				break
			j //= 10
print("")

Submission status: Accepted

Solution code:
num = int(input())
num_list = []
for n in range(3, num + 1):
    if n % 3 == 0:
        num_list.append(n)
    elif '3' in str(n):
        num_list.append(n)
print('', *num_list)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(n):
  if (i+10) % 3 == 0 or '3' in str(i+1):
    print( " ", i+1, sep = '', end = '' )

print("")

Submission status: Accepted

Solution code:
def include(a):
    while True:
        a = a // 10
        if a == 0:
            return False
        if a % 10 == 3:
            return True
n = int(input())
print('', ' '.join([str(i) for i in range(1, n + 1) if i % 3 == 0 or i % 10 == 3 or include(i)]))

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1,n+1):
    if(i%3==0 or str(i).find("3")!=-1):
        print(" %d"%i,end="")
print()

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(1,n+1):
    if '3' in str(i):a.append(i)
    elif i%3==0:a.append(i)
print(' ',end="")
print(*a)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, n+1):
    if i % 3 == 0:
        print('', i, end = '')
    elif '3' in str(i):
        print('', i, end = '')
print()

Submission status: Accepted

Solution code:
import sys


def call(n):
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            print(f' {i}', end='')
            continue
        while True:
            if x % 10 == 3:
                print(f' {i}', end='')
                break
            x //= 10
            if not x:
                break
    print()


call(int(sys.stdin.read()))

Submission status: Accepted

Solution code:
n = int(input())
for i in range(3, n+1):
    if i % 3 == 0 or "3" in str(i):
        print("", i, end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
tmp=' '
for i in range(1,n+1):
    str_i = str(i)
    if i % 3 == 0 or str_i.find('3') != -1:
        tmp += str_i + ' '
print(tmp[:-1])

Submission status: Accepted

Solution code:
x = int(input())

for i in range(1, x + 1):
    if i % 3 == 0:
        print(' ' + str(i), end='')
    elif '3' in str(i):
        print(' ' + str(i), end='')
print()

Submission status: Accepted

Solution code:
def main():
	n = int(input())
	for i in range(n):
		x = i + 1
		multipleOf3(i, x)
	print('')

def multipleOf3(i, n):
	if(n % 3) == 0:
		print(' %d' % (i + 1), end='')
	else:
		firstDigitis3(i, n)

def firstDigitis3(i, n):
	if(n % 10) == 3:
		print(' %d' % (i + 1), end='')
	else:
		n = n // 10
		if n > 0:
			firstDigitis3(i, n)

main()

Submission status: Accepted

Solution code:
n=int(input())
l=[i for i in range(3,n+1) if i%3==0 or i%10 ==3 or int(i/10)%10==3 or int(i/100)%10==3 or int(i/1000)%10==3]
s=" ".join(map(str,l))
print(" "+s)

Submission status: Accepted

Solution code:
i = int(input())

for x in range(1, i + 1) :
    tmpX = int(x // 10)
    isFinish = False

    if x % 3 == 0 :
        print(' {}'.format(x), end = '')
    elif (x % 10 == 3) :
        print(' {}'.format(x), end = '')
    elif tmpX % 10 == 3 :
        print(' {}'.format(x), end = '')
    elif tmpX != 0 :
        tmpX //= 10
        while tmpX != 0 and (not isFinish) :
            if tmpX % 10 == 3 :
                print(' {}'.format(x), end = '')
                isFinish = True
            tmpX //= 10
print()

Submission status: Accepted

Solution code:

try:
     (n)  =  int(input())
except:
    exit

i = 1
end_check = False
while True:
    x = i
    if ( x % 3 == 0):
        print(' {}'.format(i),end="")
        end_check = True

    while end_check == False:
        if ( x % 10 == 3):
            print(' {}'.format(i),end="")
            end_check = True
        x = x // 10
        if (x == 0):
            end_check =True

    i += 1
    if (i > n ):
            break
    end_check = False
print ("")

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1, n+1):
    if i % 3 == 0:
        print(" " + str(i), end="")
    else:
        x = i
        while(x):
            if x % 10 == 3:
                print(" " + str(i), end="")
                break
            x //= 10

print()

Submission status: Accepted

Solution code:
n = int(input())
answer = [" " + str(i) for i in range(1, n+1) if (i%3 == 0) or ("3" in str(i))]
print("".join(answer))

Submission status: Accepted

Solution code:
n = int(input())
ans_list = []

for i in range(1,n+1):
    x = i
    if   x%3  == 0:
        ans_list.append(' {}'.format(i))
    else:
        while x != 0:
            if x%10 == 3:
                ans_list.append(' {}'.format(i))
                break
            else:
                x //= 10

print(''.join(ans_list))

Submission status: Accepted

Solution code:
x = input()
n = int(x)

s = ''
for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        s += ' ' + str(i)
    else:
        while x != 0:
            if x % 10 == 3:
                s += ' ' + str(i)
                break
            x = int(x / 10)
print(s)

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,n+1):
    x = i
    if x%3 == 0:
        print(" {0}".format(i),end="")
    else:
        while(x):
            if x%10 ==3:
                print(" {0}".format(i),end="")
                break
            x = x//10
print()

Submission status: Accepted

Solution code:
n=int(input())
for x in range(1,n+1):
      i =x
      if(i%3==0):
          print(" {}".format(x),end="")
      else:
          while(i!=0):
             if(i%10==3):
                print(" {}".format(x),end="")
                break
             i=i//10
print()

Submission status: Accepted

Solution code:
n = int(input())
L = []
for i in range(1, n+1):
    str_i = str(i)
    if i % 3 == 0 or i % 10 == 3 or "3" in str_i:
        L.append(i)
print(" ",end="")
print(*L)

Submission status: Accepted

Solution code:
def call(n):

    for i in range(1, n+1):
        x=i
        if x % 3==0:
            print(' {0}'.format(i), end='')
        else:
            while x>0:
                if x%10==3:
                    print(' {0}'.format(i), end='')
                    break
                x //= 10

    print()

call(int(input()))

Submission status: Accepted

Solution code:
n = int(input())
List = []

for i in range(3, n+1):
    if i % 3 == 0:
        List.append(i)
    elif '3' in str(i):
        List.append(i)
        
print(' ', end = '') 
print(' '.join(map(str, List)))

Submission status: Accepted

Solution code:
n = int(input())
ans = ""
for i in range(1,n+1):
    if i % 3 == 0 or "3" in str(i):
        ans += " {}".format(i)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

lst = []
for i in range(1, x+1):
    if i % 3 == 0 or str(3) in str(i):
        lst.append(i)
        
print(' ', end='')
print(*lst)

Submission status: Accepted

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

# ITP1_5_D


# 130の場合
# 10で割ると、13
# これにまた判定をかける

# 127の場合

# 131
# 13

import math


def judge(i):
    if i%3==0:
        return str(i)
        
    newi=i
    # print(newi)
    while(newi>10):
        if newi%10==3:
            # print(newi)
            # print("ここです")
            return str(i)
        elif newi//10==3:
            # print(newi)
            # print("そこです")
            return str(i)
        newi=math.floor(newi/10)
        # print(newi)
    return False


x=int(input())
result=[]
for num in range(1,x+1):
    if(judge(num)):
        result.append(judge(num))

print(" "+" ".join(result))

Submission status: Accepted

Solution code:
n = int(input())

x = 0

for i in range(1, n+1):
    if i%3 == 0:
        print(" {}".format(i), end ="")
    else:
        x = i
        while(x):
            if x%10 == 3:
                print(" {}".format(i), end = "")
                break
            x //= 10

print()