https://www.hackerrank.com/challenges/plus-minus/problem
HackerRank - Plus Minus
x#!/bin/python3import mathimport osimport randomimport reimport sysdef plusMinus(arr): numOfElement = len(arr) numOfPlus = 0 numOfMinus = 0 numOfZero = 0 for number in arr: if(number < 0): numOfMinus += 1 elif(number > 0): numOfPlus += 1 else: numOfZero += 1 print(round(numOfPlus / numOfElement, 6)) print(round(numOfMinus / numOfElement, 6)) print(round(numOfZero / numOfElement, 6))if __name__ == '__main__': n = int(input()) arr = list(map(int, input().rstrip().split())) plusMinus(arr)
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
| HackerRank - Mini-Max Sum (0) | 2019.01.14 |
|---|---|
| HackerRank - Staircase (0) | 2019.01.13 |
| HackerRank - Diagonal Difference (0) | 2019.01.11 |
| HackerRank - A Very Big Sum (0) | 2019.01.10 |
| HackerRank - Compare the Triplets (0) | 2019.01.09 |