题解列表

筛选

题解 2815: 求特殊自然数

摘要:解题思路:注意事项:参考代码:def switch_n(n,d):    l = []    while n > 0:        l.append(str(n % d))        n = n……

统计满足条件的4位数个数

摘要:解题思路:注意事项:参考代码:n = int(input())l = list(map(int,input().split()))count = 0for i in l:    a = i%10   ……

2817: 级数求和

摘要:解题思路:注意事项:参考代码:k = int(input())s = 0n = 0while k >= s:    n += 1    s += 1/nprint(n)……

用数学的解题方式求pi

摘要:解题思路:根据题目给出的 pi/4=1-1/3+1/5-1/7...公式 可以知道分子奇数项为1,偶数项为-1,分母是公差为2的等差数列,所以分子可以写成 -1^(n-1) ,n从1开始,分母可以写成……

2819: 数字反转

摘要:解题思路:注意事项:参考代码:n = int(input())if n >= 0:    s = str(n)[::-1]    print(int(s))else:    n = -n    s =……

2820: 含k个3的数

摘要:解题思路:注意事项:参考代码:a,b = map(int,input().split())c = 0for i in str(a):    if i == '3':        c ……

STL句子拆分成单词

摘要:#include<bits/stdc++.h> using namespace std; set<string>s; int main() {     string str,c;     ……

c++的compare就是c的strcmp

摘要:#include<bits/stdc++.h> using namespace std; int main() {     string s[3];     cin>>s[0]>>s[1]>……

1852: 求1+2+3+...+n的值

摘要:解题思路:用for循环,从1累加到n。注意事项:n<=1000000000,变量得开long long。参考代码:#include<bits/stdc++.h>using namespace std;……