Math 08検索小数(1978)
Math 08小数点検索(1978)
質問する
プログラムを書き出して、与えられたN個の数の中で何個が小数であるかを見つけます.
入力
1行目の数字はNです.Nは100以下である.次はN個、数は1000以下の自然数です.
しゅつりょく
与えられた数のうちの少数の数を出力します.
に答える
コード#コード#
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)
学識
コメント
Reference
この問題について(Math 08検索小数(1978)), 我々は、より多くの情報をここで見つけました https://velog.io/@angel_eugnen/Math304소수찾기1978テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol