欧几里得求公约数:int gcd(int a, int b){ while (b) { int tmp = b; b = a % b; a = tmp; } return a;}筛选法求素数:int prime(){ memse...
分类:
其他好文 时间:
2015-03-12 18:32:57
阅读次数:
99
Problem Description
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.
Now given a humble number, please w...
分类:
其他好文 时间:
2015-03-12 17:17:24
阅读次数:
128
sizeof运算符的结果部分地依赖于其作用的类型: 对char或者类型为char的表达式执行sizeof运算结果得1; 对引用类型执行sizeof运算得到被引用对象所占空间的大小; 对指针执行sizeof运算得到指针本身所占空间的大小; 对解引用指针执行sizeof运算得到指针指向的对象所占...
分类:
编程语言 时间:
2015-03-12 06:22:07
阅读次数:
143
C++11新标准引入了一种更简单的for语句,这种语句可以遍历容器或者其他序列的所有元素。范围for语句的语法形式是: for( declaration : expression) statement expression表示的必须是一个序列,序列中的每个元素都能转换成该变量的类型。确...
分类:
编程语言 时间:
2015-03-12 06:19:35
阅读次数:
144
如果需要为某个case分支定义并初始化一个变量,我们应该把变量定义在块内,从而确保后面的所有case标签都在变量的作用域之外。case true: { // 正确,声明语句位于语句块内部 string file_name = get_file_name(...
分类:
编程语言 时间:
2015-03-12 06:17:18
阅读次数:
145
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 10000010;
int mu[maxn], prime[maxn], vis[maxn], sum[maxn];
int cnt;
int a, b;
void mobi(int n)
{
mu[1] = 1;...
分类:
其他好文 时间:
2015-03-11 17:29:53
阅读次数:
113
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 100010;
int mu[maxn], prime[maxn], vis[maxn];
int cnt;
int a, b, c, d, k;
void mobi(int n)
{
mu[1] = 1;
for(...
分类:
其他好文 时间:
2015-03-11 17:29:36
阅读次数:
147
1 #include 2 #include 3 #include 4 #define M 21 5 #define sc(x) scanf("%d",&x) 6 #define pf(x) printf("%d\n",x) 7 #define PF(x) printf("%d ",x) 8 #de....
分类:
其他好文 时间:
2015-03-11 16:22:04
阅读次数:
222
C++程序会用到的一项预处理功能是头文件保护符,头文件保护符依赖于预处理变量。预处理变量有两种状态:已定义和未定义,#define指令把一个名字设定为预处理变量,另外两个指令则分别检查某个指定的预处理变量是否已经定义:#ifdef当且仅当变量已定义的时候为真,#inndef当且仅当变量未定义时为.....
分类:
编程语言 时间:
2015-03-11 01:56:02
阅读次数:
132
decltype作用是选择并返回操作数的数据类型。 decltype(f()) sum = x; // sum的类型就是函数f的返回类型 如果decltype使用的表达式是一个变量,则decltype返回该变量的类型(包括顶层const和const在内):const int ci=0, &...
分类:
编程语言 时间:
2015-03-11 00:43:27
阅读次数:
189