­

用python做oj上的简单题(持续更新

本人刚开始接触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)