Math 08検索小数(1978)


Math 08小数点検索(1978)


質問する


プログラムを書き出して、与えられたN個の数の中で何個が小数であるかを見つけます.

入力


1行目の数字はNです.Nは100以下である.次はN個、数は1000以下の自然数です.

しゅつりょく


与えられた数のうちの少数の数を出力します.

に答える

  • 1および2ブレーク
  • for文、残りは0、破訳
  • 累計
  • cnt
  • コード#コード#

    import sys
    sys.stdin = open("input.txt","rt")
    
    
    
    def input():
        return sys.stdin.readline().rstrip()
    
    
    N = int(input())
    arr = list(map(int,input().split()))
    cnt = 0
    
    for x in arr:
        if x == 1:
            continue
        if x == 2:
            cnt +=1
            continue
        else:
            for i in range(2, x-1):
                if x%i == 0:
                    break
            else: 
                cnt+=1
    print(cnt)

    学識


    コメント