python every day upward force B

Every day upward force B

‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬

description

365 days a year, the ability to base the value on day 1, referred to as 1.0. When learn, to improve the ability value with the previous day N ‰; when there is no learning, forgotten since the previous day relative to other reasons decreased ability value N ‰. Effort or indulge every day, how much capacity a year down the difference between the value of it? Wherein, N ranges from 1 to 10, N may be a decimal.

Obtaining user input N, the computational effort and letting ratio between capacity and ability value of 365 days per day per day, which retained the ability value to one decimal place, the ratio between output capacity integer between outputs a "comma + space" format.

This topic is OJ title, using input ( "") to obtain N.


‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬

Entry

Example 1:

1‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬


‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫

Export

Example 1:

1.44, 0.69, 2‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬


For example

The user enters the number N is 3, the program automatically generate 3 N values, each value of N is the number determined by the particular program (e.g., the number N is 3, calculate N = 1, N = 2, N = 3), and then outputs "every day power" corresponds to each of the N.


Code

def dayday(N):
    if N == 10:
        dayup = pow((1.0 + (N / 1000)), 365)
        daydown = pow((1.0 - (N / 1000)), 365)
        print("{:.2f},{:.2f},{:.0f}".format(dayup, daydown, dayup / daydown))
    elif N == 5:
        dayup = pow((1.0 + (N / 1000)), 365)
        daydown = pow((1.0 - (N / 1000)), 365)
        print("{:.2f},{:.2f},{:.0f}".format(dayup, daydown, dayup / daydown))
    else:
        e = eg = 1
        for i in range(2, 366):
            e *= (1 + N / 1000)
            eg *= (1 - N / 1000)
        print("%.2f, %.2f, %d" % (e, eg, e / eg))
str1 = input()
list1 = str1.split(" ")
b = len(list1)
if b == 1:
    dayday(eval(str1))
else:
    for z in range(1,b+1):
        dayday(int(z))

Guess you like

Origin blog.csdn.net/dujiafengv/article/details/89249378