题目链接:点击打开链接
题目大意:给出m种颜色的小球,现在要求用n个串成一个环,经过旋转翻转后,能形成多少个不同的环。
参考:点击打开链接
#include
#include
#include
#include
using namespace std ;
#define LL __int64
LL gcd(LL a,LL b) {
return b == 0 ? a ...
分类:
其他好文 时间:
2015-07-28 10:43:29
阅读次数:
148
#includeusing namespace std;bool match(char *str,char* pattern){ if(*str=='\0'&&*pattern=='\0') return true; if(*str!='\0'&&*pattern=='\0') return f.....
分类:
其他好文 时间:
2015-07-28 10:34:23
阅读次数:
121
int main()括号里面为空代表不确定参数,并不是说不带参数。如果要告诉编译器函数不带参数,做法是:int main(void)int main()需要返回一个整形值,也就是我们经常会看到在这个函数末尾会加上return 0void main()代表这个函数不需要返回任何值,比如:void pr...
分类:
其他好文 时间:
2015-07-28 10:15:52
阅读次数:
81
进程退出 进程结束表示进程即将结束运行,在linux系统中进程的退出方法分为正常退出和异常退出两种.exit函数进程有三种正常终止法及两种异常终止法。(1) 正常终止: (a) 在main函数内执行return语句。这等效于调用 exit。 (b) 调用exit函数。此函数由ANSI C定义,其操作...
分类:
系统相关 时间:
2015-07-28 10:14:26
阅读次数:
168
【046-Permutations(求排列)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a collection of numbers, return all possible permutations.
For example,
[1,2,3] have the following permutations:
[1,2,3], [1,...
分类:
编程语言 时间:
2015-07-28 06:43:13
阅读次数:
129
Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return the coordinate of the left-up and right-down numbe...
分类:
其他好文 时间:
2015-07-28 06:40:25
阅读次数:
139
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1
Input:...
分类:
其他好文 时间:
2015-07-28 01:00:43
阅读次数:
108
这个题坑极多,附代码和测试数据,如果测试数据都过了,基本上就能AC了,希望对大家有所帮助#include
#include
#include
int cmp(const void*a, const void*b)
{
return *(int*)a - *(int*)b;
}
int main()
{
int m, n,...
分类:
其他好文 时间:
2015-07-28 00:54:15
阅读次数:
116
Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m...
分类:
其他好文 时间:
2015-07-28 00:49:13
阅读次数:
132
一.冒泡排序var bubble = function(arr){for(i=0;i arr[j+1]){temp = arr[j];arr[j] = arr[j+1];arr[j+1] = temp;}}}return arr;} 二.插入排序var insersort = function(ar...
分类:
编程语言 时间:
2015-07-28 00:47:24
阅读次数:
155