Happy 2004(快速幂+乘法逆元)】的更多相关文章

题目链接: Reading comprehension Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) Problem Description   Read the program below carefully then answer the question.#pragma comment(linker, "/STACK:1024000000,1024000000&quo…
1.乘法逆元 直接使用等比数列求和公式,注意使用乘法逆元 ---严谨,失细节毁所有 #include "bits/stdc++.h" using namespace std; #define rep(i, s, n) for(int i=s;i<n;i++) #define MOD 1000000007 #define LL long long ; LL quick_pow(LL a,LL b) { LL ans=; ){ ){ ans=ans*a%MOD; } b>>…
Happy 2004 问题描述 : Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an example. The positive integer divisors of 2…
题目链接: All X Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description   F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c   Input   第一行一个整数T,表示T组数据.每组测试数据占一行,包含四个数字x,m,k,c 1≤x≤9 1≤m≤10^10 0≤c<k≤10,…
A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 865    Accepted Submission(s): 534 Problem Description There are an equation.∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?We define…
题意: 给出n次翻转和m张牌,牌相同且一开始背面向上,输入n个数xi,表示xi张牌翻转,问最后得到的牌的情况的总数. 思路: 首先我们可以假设一开始牌背面状态为0,正面则为1,最后即是求ΣC(m,k),k为所有能取到1的情况.首先我们要确认最后1的奇偶性.因为一次翻转0->1,或者1->0,则最后所有1的情况的奇偶性相同.然后我们要找到最小的1的个数i和最大的1的个数j,i为能翻1则翻1,j为能翻0则翻0,介于中间的情况是取偶数步数,一半翻1,一半翻0,保持1的个数不变.那么k为(i<=…
Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an example. The positive integer divisors of 2004^1 are 1, 2, 3,…
题目描述 给定一个多项式(by+ax)^k,请求出多项式展开后x^n*y^m 项的系数. 输入输出格式 输入格式: 输入文件名为factor.in. 共一行,包含5 个整数,分别为 a ,b ,k ,n ,m,每两个整数之间用一个空格隔开. 输出格式: 输出共1 行,包含一个整数,表示所求的系数,这个系数可能很大,输出对10007 取模后的结果. 输入输出样例 输入样例#1: 1 1 3 1 2 输出样例#1: 3 说明 [数据范围] 对于30% 的数据,有 0 ≤k ≤10 : 对于50% 的…
方便复制 快速乘/幂 时间复杂度 \(O(\log n)\). ll nmod; //快速乘 ll qmul(ll a,ll b){ ll l=a*(b>>hb)%nmod*(1ll<<hb)%nmod; ll r=a*(b&((1<<hb)-1))%nmod; return (l+r)%nmod; } //快速幂 ll qpow(ll a,ll b){ ll res=1; while(b){ if(b&1)res=res*a%nmod; a=a*a%n…
是2017江苏省赛的第一题,当时在场上没做出来(废话,那个时候又不懂高斯消元怎么写……而且数论也学得一塌糊涂,现在回来补了) 省赛结束之后,题解pdf就出来了,一看题解,嗯……加一行再求逆矩阵从而得到伴随矩阵从而得到答案,emmmmm真是非常通俗易懂呢! 于是在回学校的路上强行回忆上学期学的线性代数,把这题题解的原理想通了,然后到现在把高斯消元法补了,才把这题做出来…… #include<cstdio> #include<algorithm> #define MAXN 205 #d…