复杂度 O(N) bool isPrime[1000001]; //isPrime[i] == 1表示:i是素数 int Prime[1000001], cnt = 0; //Prime存质数 void GetPrime(int n)//筛到n { memset(isPrime, 1, sizeof ...
分类:
其他好文 时间:
2019-11-24 11:52:07
阅读次数:
65
#include <iostream> #include <stdio.h> using namespace std; int g_szArray[] = { 7, 3, 5, 8, 9, 1, 2, 4, 6 }; void main() { int nLen = sizeof(g_szArray... ...
分类:
编程语言 时间:
2019-11-24 11:50:57
阅读次数:
59
#include <stdio.h>#include <string.h>#include<stdlib.h>void testArr(const char str[]){ printf("%lu %lu\n", sizeof(str), strlen(str));}int main(void){ ...
分类:
其他好文 时间:
2019-11-23 22:12:31
阅读次数:
75
0202 转义字符‘[]’中的‘-’是执行时定义的。不要这么用。 #include <stdio.h> extern void foo(char *cptr) { scanf("Total %[a-z]", cptr); /* Message 0202 */ } https://stackoverf ...
分类:
其他好文 时间:
2019-11-23 22:07:25
阅读次数:
115
题意:求一条链 $(u,v)$ 上不同的颜色数。 我们可以求出树的出栈入栈序(or 括号序?我也不确定)。 图(from "attack" ) 然后有一个很优美的性质: 设点 $u$ 的入栈时间为 $dfn[u]$ ,出栈时间为 $low[u]$ 设两个点 $u,v$ 满足 $dfn[u] incl ...
分类:
其他好文 时间:
2019-11-23 21:47:05
阅读次数:
74
首先让我们来认识顺序表 在顺序存储结构中,以数据元素的长度为单位,所以每个元素之间的距离为L。 在顺序存储结构中,数据的存储位置和它们的物理位置一致,因此较为简单、自然 使用C语言描述顺序存储结构下的线性表代码如下: 需要注意的有以下问题 (1)数组的长度和线性表的长度不是一个概念。数组的长度是存放 ...
分类:
其他好文 时间:
2019-11-22 00:55:14
阅读次数:
105
//f[u][0]是所有以u为根的子树中选择,并且不选u这个点的方案 //f[u][1]是所有以u为根的子树中选择,并且 选u这个点的方案 #include <cstring> #include <iostream> #include <algorithm> using namespace std; ...
练习7-1 #include <stdio.h> int main() { int n; printf("%d\t%d\t%d\n", sizeof 1,sizeof(unsigned)-1,sizeof n+2 ); //此行显示结果为 4 3 6 因为1的字节就是为4,而-1的字节也是4再减去- ...
分类:
编程语言 时间:
2019-11-19 13:32:51
阅读次数:
181
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> int main(void) { int n; printf("请输入需要输入的整数的数量:"); scanf("%d", &n); // 确定深度 in ...
分类:
编程语言 时间:
2019-11-17 23:37:04
阅读次数:
101
C++ 数组遍历的两种方式: #include <iostream> using namespace std; int main() { // 一维数组 int fibonacci[5] = {1, 1, 2, 3, 5}; // 使用索引遍历 // 求数组长度:sizeof(array)/size ...
分类:
编程语言 时间:
2019-11-17 01:41:35
阅读次数:
254