长度为l的用k种字符组成的字符串有k^l中 当中m个字符要不同样 那就是k^l*C(l, m)*(k-1)^m 有反复 要除以2 可是你mod n了 不能直接除 n不一定是素数 所以不能乘以逆元 所以我都mod 2倍的n 最后的结果再除以2 特判l = 1 和 m = 0的情况 #include <cstdio> #include <cstring> #include <cmath> using namespace std; typedef long long LL;…
链接: https://vjudge.net/problem/LightOJ-1318 题意: In a country named "Ajob Desh", people play a game called "Ajob Game" (or strange game). This game is actually a game of words. The rules for the game are as follows: It's an N player gam…
题目大意: 给你一个字符串,问这个字符串按照特定顺序排列之后,第n个字符串是哪个? 题目分析: 首先我们要会求解总个数.也就是共有len个字符,每个字符有ki个,那么总组合方式是多少种? 总组合方式就是: (len!)/(ki !), 把每个ki的阶乘都除一边,最后算出的结果就是答案了. 那么问题就剩下解决第n个字符串的的问题了. 下面我们先了解一下排序计数: 排序计数 如1,2,3,4的全排列,共有4!种,求第10个的排列是(从1计起)? 先试首位是1,后234有3!=6种<10,说明首位1偏…
题目来源:Light OJ 1288 Subsets Forming Perfect Squares 题意:给你n个数 选出一些数 他们的乘积是全然平方数 求有多少种方案 思路:每一个数分解因子 每隔数能够选也能够不选 0 1表示 然后设有m种素数因子 选出的数组成的各个因子的数量必须是偶数 组成一个m行和n列的矩阵 每一行代表每一种因子的系数 解出自由元的数量 #include <cstdio> #include <cstring> #include <algorithm&…
Problem Description During summer vacation,Alice stay at home for a long time, with nothing to do. She went out and bought m pokers, tending to play poker. But she hated the traditional gameplay. She wants to change. She puts these pokers face down,…
3209: 花神的数论题 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2498  Solved: 1129[Submit][Status][Discuss] Description 背景众所周知,花神多年来凭借无边的神力狂虐各大 OJ.OI.CF.TC …… 当然也包括 CH 啦.描述话说花神这天又来讲课了.课后照例有超级难的神题啦…… 我等蒟蒻又遭殃了.花神的题目是这样的设 sum(i) 表示 i 的二进制表示中 1 的个数.给出一个正整数…
Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13959   Accepted: 3433 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 99…
zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 448    Accepted Submission(s): 147 Problem Description As one of the most powerful brushes, zhx is required to give his juniors n p…
UVA 11551 - Experienced Endeavour 题目链接 题意:给定一列数,每一个数相应一个变换.变换为原先数列一些位置相加起来的和,问r次变换后的序列是多少 思路:矩阵高速幂,要加的位置值为1.其余位置为0构造出矩阵,进行高速幂就可以 代码: #include <cstdio> #include <cstring> const int N = 55; int t, n, r, a[N]; struct mat { int v[N][N]; mat() {mem…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4869 题意:有m张扑克.開始时所有正面朝下.你能够翻n次牌,每次能够翻xi张.翻拍规则就是正面朝下变背面朝下,反之亦然,问经过n次翻牌后牌的朝向有多少种情况. 这道题在比赛时我们仅仅开了个头.却无从下手. 我看了网上的解题报告.说的都比較简单,对于我这名菜鸟来说也想了比較长的时间才想明确,所以我想写的清晰一些日后再看还能看的非常清晰. 思路是这样,每张牌翻奇数次必定是正面朝上.翻偶数次则还是正面朝下.如…