整数的阶:设a和n是互素的正整数,使得a^x=1(mod n)成立的最小的正整数x称为a模n的阶 //求阶模板:A^x=1(mod M),调用GetJie(A,M) //输入:10^10>A,M>1 //输出:无解返回-1,有解返回最小正整数x //复杂度:O(M^(0.5)) long long gcd(long long a,long long b) { ) return a; return gcd(b,a%b); } //欧拉函数:复杂度O(n^(0.5)),返回[1,n-1]中所有和n…
题目链接:pid=1084">点击打开链接 寒假安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others) SubmitStatistic Next Problem Problem Description 寒假又快要到了,只是对于lzx来说,头疼的事又来了,由于众多的后宫都指望着能和lzx约会呢,lzx得安排好计划才行. 如果lzx的后宫团有n个人.寒假共同拥有m天,而每天仅仅能…
/** * 找出未出现的最小正整数 * @param A * @param n * @date 2016-10-7 * @author shaobn */ public static int findArrayMex(int[] a,int n){ int count = n; int temp = 0; int dir = 1; int num = 0; for(int i = 0;i<count-1;i++){ if(a[i]>a[i+1]){ temp = a[i]; a[i]= a[i…
[题目] Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. [思路] 注意sort,使得判断临接元素是否相邻. 与leetcode78类似,多了一个重复数判断条件 if(i>flag&&nums…