From 8c25746b0be96d01642780f3557454a11984641f Mon Sep 17 00:00:00 2001 From: 10_2 Date: Sat, 13 Jul 2024 10:49:07 +0800 Subject: [PATCH] Signed-off-by: 10_2 --- .idea/.gitignore | 3 + .idea/.name | 1 + .idea/codeStyles/codeStyleConfig.xml | 5 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/刘天硕.iml | 8 ++ 2024-5-31-1.py | 20 +++++ 2024-6-14-1.py | 10 +++ 2024-6-14-2.py | 7 ++ 2024-6-16-1.py | 27 ++++++ 2024-6-2-1.py | 13 +++ 2024-6-2-2.py | 6 ++ 2024-6-2-3.py | 12 +++ 2024-6-2-4.py | 6 ++ 2024-6-2-5.py | 7 ++ 2024-6-20-1.py | 3 + 2024-6-20-2.py | 6 ++ 2024-6-23-1.py | 4 + 2024-6-23-2.py | 11 +++ 2024-6-23-3.py | 8 ++ 2024-6-28-1.py | 11 +++ 2024-6-7-1.py | 20 +++++ 2024-7-10-1.py | 37 ++++++++ 2024-7-10-2.py | 84 +++++++++++++++++++ 2024-7-11-1.py | 10 +++ 2024-7-11-2.py | 20 +++++ 2024-7-12-1.py | 9 ++ 2024-7-9-1.py | 14 ++++ B2077 角谷猜想.py | 13 +++ B3841 [GESP202306 二级] 自幂数判断.py | 28 +++++++ 31 files changed, 421 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/刘天硕.iml create mode 100644 2024-5-31-1.py create mode 100644 2024-6-14-1.py create mode 100644 2024-6-14-2.py create mode 100644 2024-6-16-1.py create mode 100644 2024-6-2-1.py create mode 100644 2024-6-2-2.py create mode 100644 2024-6-2-3.py create mode 100644 2024-6-2-4.py create mode 100644 2024-6-2-5.py create mode 100644 2024-6-20-1.py create mode 100644 2024-6-20-2.py create mode 100644 2024-6-23-1.py create mode 100644 2024-6-23-2.py create mode 100644 2024-6-23-3.py create mode 100644 2024-6-28-1.py create mode 100644 2024-6-7-1.py create mode 100644 2024-7-10-1.py create mode 100644 2024-7-10-2.py create mode 100644 2024-7-11-1.py create mode 100644 2024-7-11-2.py create mode 100644 2024-7-12-1.py create mode 100644 2024-7-9-1.py create mode 100644 B2077 角谷猜想.py create mode 100644 B3841 [GESP202306 二级] 自幂数判断.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..c3478d3 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +2024-7-9-1.py \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..dc9ea49 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..eb0dcf7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/刘天硕.iml b/.idea/刘天硕.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/刘天硕.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2024-5-31-1.py b/2024-5-31-1.py new file mode 100644 index 0000000..87617dd --- /dev/null +++ b/2024-5-31-1.py @@ -0,0 +1,20 @@ +a_set={'1','1','1'} +print(a_set) +b_set={'l','t','s'} +print(b_set) +c='I love python' +d=set(c) +print(d) + +c=('4','5','6','7','8','9') +d=set(c) +print(d) + +r={1,2,3,4,5,6} +print(len(r)) +''' +set:集合 +frozen:冰冻 +frozenset:不可变集合 +''' + diff --git a/2024-6-14-1.py b/2024-6-14-1.py new file mode 100644 index 0000000..fc9fa2b --- /dev/null +++ b/2024-6-14-1.py @@ -0,0 +1,10 @@ +def pan(a,b,c): + if a+b>c and b+c>a and a+c>b: + print() + else: + print() + +q=int(input()) +w=int(input()) +e=int(input()) +pan(a,b,c) diff --git a/2024-6-14-2.py b/2024-6-14-2.py new file mode 100644 index 0000000..e2ed35c --- /dev/null +++ b/2024-6-14-2.py @@ -0,0 +1,7 @@ +a=int(input()) +b=0 +for i in range(2,a): + if a%i==0: + b=i + break +print(int(a/b)) diff --git a/2024-6-16-1.py b/2024-6-16-1.py new file mode 100644 index 0000000..9711b9d --- /dev/null +++ b/2024-6-16-1.py @@ -0,0 +1,27 @@ +a=int(input()) +s=0 +d=1 +e=0 +if a%2==0: + e=int(a/2) +else: + e=int(a/2+0.5) +for i in range(1,e+1): + if i%2==0: + s-=1/d + else: + s+=1/d + d+=2 +print(round(s,8)) + + +count=1 +sum=0 +for i in range(1,a+1,2): + if count%2: + sum+=1/i + else: + sum-=1/i + count+=1 +print(round(sum,8)) + diff --git a/2024-6-2-1.py b/2024-6-2-1.py new file mode 100644 index 0000000..a7aaa53 --- /dev/null +++ b/2024-6-2-1.py @@ -0,0 +1,13 @@ +k=int(input()) +l=int(input()) +r=int(input()) + +s=0 + +for i in range(l,r+1): + if i%10==k: + s+=i + elif i%k==0: + s+=i + +print(s) diff --git a/2024-6-2-2.py b/2024-6-2-2.py new file mode 100644 index 0000000..5435c2e --- /dev/null +++ b/2024-6-2-2.py @@ -0,0 +1,6 @@ +xingrun=int(input()) +guli=int(input()) +if xingrun>=10 or guli>=20: + print(1) +else: + print(0) diff --git a/2024-6-2-3.py b/2024-6-2-3.py new file mode 100644 index 0000000..249e80b --- /dev/null +++ b/2024-6-2-3.py @@ -0,0 +1,12 @@ +yu=int(input()) +shu=int(input()) +ying=int(input()) + +if yu<60 and shu>=60 and ying>=60: + print(1) +elif yu>=60 and shu<60 and ying>=60: + print(1) +elif yu>=60 and shu>=60 and ying<60: + print(1) +else: + print(0) diff --git a/2024-6-2-4.py b/2024-6-2-4.py new file mode 100644 index 0000000..f6ef165 --- /dev/null +++ b/2024-6-2-4.py @@ -0,0 +1,6 @@ +start_h=int(input()) +start_m=int(input()) +end_h=int(input()) +end_m=int(input()) + +print((end_h*60+end_m)-(start_h*60+start_m)) diff --git a/2024-6-2-5.py b/2024-6-2-5.py new file mode 100644 index 0000000..4ea66e0 --- /dev/null +++ b/2024-6-2-5.py @@ -0,0 +1,7 @@ +num=int(input()) +anser=0 + +for i in range(1,num+1): + anser+=i*num + num-=1 +print(anser) diff --git a/2024-6-20-1.py b/2024-6-20-1.py new file mode 100644 index 0000000..9e641a3 --- /dev/null +++ b/2024-6-20-1.py @@ -0,0 +1,3 @@ +a=int(input()) +print(a//13) +print(a%13) diff --git a/2024-6-20-2.py b/2024-6-20-2.py new file mode 100644 index 0000000..f5b27a8 --- /dev/null +++ b/2024-6-20-2.py @@ -0,0 +1,6 @@ +n=int(input()) +for i in range(1,n+1): + if n%i==0: + print(i) + + diff --git a/2024-6-23-1.py b/2024-6-23-1.py new file mode 100644 index 0000000..5b21d1f --- /dev/null +++ b/2024-6-23-1.py @@ -0,0 +1,4 @@ +import turtle +turtle.circle(150,steps=4) +turtle.done() + diff --git a/2024-6-23-2.py b/2024-6-23-2.py new file mode 100644 index 0000000..e9a4a13 --- /dev/null +++ b/2024-6-23-2.py @@ -0,0 +1,11 @@ +a=int(input()) +b=int(input()) +if b==2: + if a%4==0 and a%100!=0 or a%400==0: + print(29) + else: + print(28) +elif b==1 or 3 or 5 or 7 or 8 or 10 or 12: + print(31) +else: + print(30) \ No newline at end of file diff --git a/2024-6-23-3.py b/2024-6-23-3.py new file mode 100644 index 0000000..bc42f1c --- /dev/null +++ b/2024-6-23-3.py @@ -0,0 +1,8 @@ +a=int(input()) +b=int(input()) +c=int(input()) +d=input() +if d=="a": + print(a*60*60+b*60+c) +elif d=="p": + print(12*60*60+a * 60 * 60 + b * 60 + c) \ No newline at end of file diff --git a/2024-6-28-1.py b/2024-6-28-1.py new file mode 100644 index 0000000..5fc1513 --- /dev/null +++ b/2024-6-28-1.py @@ -0,0 +1,11 @@ +a=int(input()) +b=65 +for i in range(1,a+1): + for p in range(1,i+1): + print(chr(b),end=" ") + b+=1 + if b>90: + b=65 + print("") + + diff --git a/2024-6-7-1.py b/2024-6-7-1.py new file mode 100644 index 0000000..a481e06 --- /dev/null +++ b/2024-6-7-1.py @@ -0,0 +1,20 @@ +a={"h","j","e"} +a.add("e") +print(a) + +""" +intersection:相交 +differece:差别 +union:同盟,联合,并集 +symmetric_differece():表示对称差集 +disjoint:不相交的 +subset:子集,分组 +superset:父集,超集 +""" + +a=int(input()) +s=0 +for i in range(1,a+1): + s+=i +print(s) + diff --git a/2024-7-10-1.py b/2024-7-10-1.py new file mode 100644 index 0000000..46e8484 --- /dev/null +++ b/2024-7-10-1.py @@ -0,0 +1,37 @@ +#(lambda 形参,形参:表达式)(实参,实参) lambda函数 +print((lambda x,y=3:x*y)(8)) + +def fun(x): + if x%2: + return None + else: + return x +x=int(input()) +print(fun(x)) + +#filter(形参,[实参,实参,实参,实参'实参']) filter函数 +print(list(filter(None,[0,1,2,3,4,5,6,7,8,9,10,""," ","六",False,[],()]))) +print(tuple(filter(None,[0,1,2,3,4,5,6,7,8,9,10,""," ","六",False,[],()]))) + +def f(u): + print("Hello,Python!") + if u%2==0: + return True + else: + return False +print(list(filter(f,[0,12,2,37,56,43,53,77,90]))) + +#1-100奇数求和 +a=0 +for i in range(1,101,2): + a+=i +print(a) + +print(sum(list(range(1,101,2)))) + +#sorted默认为升序排序 +print(sorted([2,65,321,124])) + +#高于5000的工资 +salaries={"Jack":3000,"Alex":6000,"Dannle":4000,"Anne":10000,"Charlie":5100} +print(list(filter(lambda k:salaries[k]>5000,salaries))) \ No newline at end of file diff --git a/2024-7-10-2.py b/2024-7-10-2.py new file mode 100644 index 0000000..ccfdf84 --- /dev/null +++ b/2024-7-10-2.py @@ -0,0 +1,84 @@ +b=int(input()) +c=int(input()) +import turtle +t=turtle.Turtle() +a=turtle.Turtle() +t.speed(0) +a.speed(0) +t.left(90) +t.pensize(5) +a.pensize(5) +t.goto(0,0) +a.penup() +a.goto(200,0) +a.pendown() +d=0 +e=0 +f=0 +g=0 +while 1: + for i in range(10): + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor(e,f,g) + t.forward(c) + t.left(360/b) + a.pencolor(e,f,g) + a.forward(c) + a.left(360/b) + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor("white") + t.forward(c) + t.left(360/b) + a.pencolor("white") + a.forward(c) + a.left(360/b) + d=d+1 + e=d/10 + if e>0.9: + e=0 + d=0 + f=f+0.1 + if f>0.9: + f=0.1 + g=g+0.1 + if g>0.9: + g=0 + a.backward(20) + for i in range(2): + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor(e,f,g) + t.forward(c) + t.left(360/b) + a.pencolor(e,f,g) + a.forward(c) + a.left(360/b) + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor("white") + t.forward(c) + t.left(360/b) + a.pencolor("white") + a.forward(c) + a.left(360/b) + t.forward(c) + for i in range(10): + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor(e,f,g) + t.forward(c) + t.left(360/b) + a.pencolor(e,f,g) + a.forward(c) + a.left(360/b) + for i in range(b):#for循环结构,range()函数,迭代器,list,tuple... + t.pencolor("white") + t.forward(c) + t.left(360/b) + a.pencolor("white") + a.forward(c) + a.left(360/b) + a.backward(20) + t.goto(0,0) + a.penup() + a.goto(200,0) + a.pendown() +turtle.down() + diff --git a/2024-7-11-1.py b/2024-7-11-1.py new file mode 100644 index 0000000..95e9476 --- /dev/null +++ b/2024-7-11-1.py @@ -0,0 +1,10 @@ +#map(函数,不定长迭代器) map函数 +#题目要求:已知列表[1,2,3,4,5,6,7,8,9],请你返回一个x*x的列表. +li=[1,2,3,4,5,6,7,8,9] +print(list(map(lambda x:x*x,li))) + +#导入functools,才可使用reduce函数 +#functools.reduce(函数对象,序列,初始数据) +import functools +list1=["a","b","c","Python"] +print(functools.reduce(lambda a,b:a+b,list1,"Hello")) diff --git a/2024-7-11-2.py b/2024-7-11-2.py new file mode 100644 index 0000000..7deeefe --- /dev/null +++ b/2024-7-11-2.py @@ -0,0 +1,20 @@ +list=[] +list1=[] +u=int(input()) +for i in range(u): + list.append(int(input())) +for i in list: + a=i + b=0 + num=a + while a!=0: + list1.append(a%10) + a=a//10 + b+=1 + q=0 + for t in list1: + q+=t**b + if q==num: + print("T") + else: + print("F") \ No newline at end of file diff --git a/2024-7-12-1.py b/2024-7-12-1.py new file mode 100644 index 0000000..869cca7 --- /dev/null +++ b/2024-7-12-1.py @@ -0,0 +1,9 @@ +a=int(input()) +b=int(input()) +c=int(input()) + +d=min(min(a,b),c) +for i in range(d,0,-1): + if a%i==0 and b%i==0 and c%i==0: + print(i) + break \ No newline at end of file diff --git a/2024-7-9-1.py b/2024-7-9-1.py new file mode 100644 index 0000000..0543878 --- /dev/null +++ b/2024-7-9-1.py @@ -0,0 +1,14 @@ +list=[] +n=int(input()) +for i in range(n): + list.append(int(input())) +for i in list: + num=i + result=0 + for x in range(1,int((num/2)**0.5)+1): + if num-x**2==(int((num-x**2)**0.5))**2: + print("YES") + result=1 + break + if result==0: + print("NO") \ No newline at end of file diff --git a/B2077 角谷猜想.py b/B2077 角谷猜想.py new file mode 100644 index 0000000..1de0d12 --- /dev/null +++ b/B2077 角谷猜想.py @@ -0,0 +1,13 @@ +def jiaogu(n): + if n==1: + print("End") + return 1 + if n%2==0: + print(n,"/",2,"=",n//2,sep="") + jiaogu(n//2) + else: + print(n, "*", 3, "+",1,"=" ,n * 3+1, sep="") + jiaogu(n*3+1) + +n=int(input()) +jiaogu(n) \ No newline at end of file diff --git a/B3841 [GESP202306 二级] 自幂数判断.py b/B3841 [GESP202306 二级] 自幂数判断.py new file mode 100644 index 0000000..ee8a4cd --- /dev/null +++ b/B3841 [GESP202306 二级] 自幂数判断.py @@ -0,0 +1,28 @@ +#自幂数判断函数 +def is_zimi(x): + weishu=[] + count=0 + num=x + #拆位求解 + while x!=0: + weishu.append(x%10) + x=x//10 + count+=1 + #位数求和 + sum=0 + for i in weishu: + sum+=pow(i,count) + #自幂数判断 + if sum==num: + return "T" + else: + return "F" + +#输入多个数字 +numbers=[] +n=int(input()) +for i in range(n): + numbers.append(int(input())) +#循环判断是否是自幂数 +for i in numbers: + print(is_zimi(i)) \ No newline at end of file