51nod
XSamsara
AFO
展开
-
[51nod]2129 逆置换 【暴力】
2129 逆置换 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 输入一个1到n的排列,p[1], p[2], …, p[n], 即1到n都出现了1次的一个长度为n的数组p。 对于每个满足1 <= i <= n的i,求下标j使得p[j] = i。 1 <= n <= 100000 Input 第一行一个整数n,表示排列长度...原创 2018-04-17 09:15:19 · 363 阅读 · 1 评论 -
[51nod]2128 前缀异或【数学题】
2128 前缀异或 基准时间限制:2 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 输入一个长度为n(1<=n<=100000)n(1<=n<=100000)n(1 a[1],a[2],...,a[n]a[1],a[2],...,a[n]a[1], a[2], ..., a[n]。 输入一个询问数m(1<=m<=100000)m(1&...原创 2018-04-17 08:48:38 · 316 阅读 · 0 评论 -
[51nod]1003 阶乘后面0的数量 【数学题】
我们知道,10的因子是2和5,那么我们就求出N!中2的因子和5的因子数,取个小的就是答案,因为N!中5这个质因子肯定少于2,那么就直接求5这个质因子个数就可以了。 #include<cstdio> using namespace std; int n; int get(int x,int y){ int sum=0; for(;x;x/=y) sum+=x/y; ...原创 2018-04-10 14:14:20 · 123 阅读 · 0 评论 -
[51nod]1004 n^n的末位数字 【快速幂】
1004 n^n的末位数字 可以看成mod 10后的结果,因为m很大所以要用到快速幂。 #include<cstdio> using namespace std; int n,ans=1; void qsm(int A,int B){for(int w=A;B;B>>=1,w=(w*w)%10) if(B&1) ans=(ans*w)%10;} int ma...原创 2018-04-10 14:04:56 · 177 阅读 · 0 评论 -
[51nod]1668 非010串【矩阵乘法】
1668 非010串 【题目描述】 传送门 【题解】 先求出递推式,然后用矩阵乘法求解。 代码如下 #include<cstdio> #include<cstring> #include<iostream> #define LL long long using namespace std; const LL MOD=1e9+7; LL n; ...原创 2018-05-24 21:42:55 · 186 阅读 · 0 评论