用python做oj上的簡單題(持續更新
- 2020 年 1 月 9 日
- 筆記
本人剛開始接觸python,在oj上解一些簡單的題,歡迎交流,不喜勿噴.
OJ地址鏈接:acm.sdut.edu.cn
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1110&cid=1278
#!/usr/bin/env python # coding=utf-8 print 'Hello World!'
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1000
#!/usr/bin/env python # coding=utf-8 a=raw_input().split() print int(a[0])+int(a[1])
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1111&cid=1278
#!/usr/bin/env python # coding=utf-8 print '100' print 'A' print '3.140000'
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1117&cid=1279
#!/usr/bin/env python # coding=utf-8 x = input() print abs(x)
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1115&cid=1279
#!/usr/bin/env python # coding=utf-8 x = raw_input().split() print x[1],x[0]
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1208&cid=1279
#!/usr/bin/env python # coding=utf-8 f = input() c = 5*(f - 32)/9 print ("%.2f"% c)
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1116&cid=1279
#!/usr/bin/env python # coding=utf-8 import string x = raw_input() print x.upper()
題目內容: 對於三角形,三邊長分別為a, b, c,給定a和b之間的夾角C,則有:。編寫程式,使得輸入三角形的邊a, b, c,可求得夾角C(角度值)。 輸入格式: 三條邊a、b、c的長度值,每個值佔一行。 輸出格式: 夾角C的值,保留1位小數。 輸入樣例: 3 4 5 輸出樣例: 90.0 時間限制:500ms記憶體限制:32000kb
#!/usr/bin/env python # coding=utf-8 from math import acos from math import pi a = input() b = input() c = input() x = a*a+b*b-c*c y = x/2/a/b z = acos(y) print round(z*180/pi,1)
假設你每年初往銀行賬戶中1000元錢,銀行的年利率為4.7%。
一年後,你的賬戶餘額為:
1000 * ( 1 + 0.047) = 1047 元
第二年初你又存入1000元,則兩年後賬戶餘額為:
(1047 + 1000) * ( 1 + 0.047) = 2143.209 元
以此類推,第10年年末,你的賬戶上有多少餘額?
註:結果保留2位小數(四捨五入)。
#!/usr/bin/env python # coding=utf-8 a = 1047 i=0 while i < 9: a = (a+1000) * 1.047 i = i + 1 print round(a,2)