- 博客(8)
- 收藏
- 关注
原创 完数与盈数(时间复杂度极低的算法)
题目描述一个数如果恰好等于它的各因子(该数本身除外)子和,如:6=3+2+1,则称其为“完数”;若因子之和大于该数,则称其为“盈数”。求出2 到60 之间所有“完数”和“盈数”,并以如下形式输出: E: e1 e2 e3 …(ei 为完数) G: g1 g2 g3 …(gi 为盈数)输入无输出按描述要求输出(注意EG后面的冒号之后有一个空格)。如果题目范围为2~n,当n很大时,普通的方法会需要很长时间对因子进行求和。以下算法更好。```cpp#include <stdio.h&g
2021-02-16 15:25:45
326
原创 各种排序算法
各种排序算法#include <stdio.h>void DirectInsertSort(int a[], int n){ int temp; for(int i = 1; i < n; i++){ temp = a[i]; int j; for(j = i - 1; j >= 0 && a[j] > temp; j--) a[j + 1] = a[j];
2020-11-18 21:27:56
184
原创 快速幂取模的迭代方法
#include <stdio.h>typedef long long LL;LL pow(LL a, LL b, LL m){ LL ans = 1; for(int i = 0; i < b; i++){ ans = ans * a % m; } return ans;}int BinaryPow(int a, int b, int m){ if(b == 0) return 1; if(b &
2020-06-26 19:08:15
222
原创 写代码的时候打错字,好烦
//快速求a^b%m```cpp#include <stdio.h>typedef long long LL;LL pow(LL a, LL b, LL m){ LL ans = 1; for(int i = 0; i < b; i++){ ans = ans * a % m; } return ans;}int BinaryPow(int a, int b, int m){ if(b == 0) return
2020-06-24 22:40:57
329
原创 codeup
问题 C: To Fill or Not to Fill[命题人 : 外部导入]时间限制 : 1.000 sec 内存限制 : 32 MB题目描述With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time
2020-06-15 00:59:03
169
原创 codeup
题目描述Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, “helloworld” can be printed as:h de ll rlowoThat is, the characters must ...
2020-03-11 22:29:22
158
原创 三维字符数组
题目描述输入N个学生的信息,然后进行查询。输入输入的第一行为N,即学生的个数(N<=1000)接下来的N行包括N个学生的信息,信息格式如下:01 李江 男 2102 刘唐 男 2303 张军 男 1904 王娜 女 19然后输入一个M(M<=10000),接下来会有M行,代表M次查询,每行输入一个学号,格式如下:02030104输出输出M行,每行包括一个对...
2020-03-07 23:40:44
2684
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人