本人剛開始接觸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)