这个西安赛区大概是我们学校打得最好的一次了,因为数学题多,而且嘛,那个I竟然就是暴力,恭喜我们学校分了个机会
Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is \frac{q}{p}(\frac{q}{p} \le \frac{1}{2})pq(pq≤21).
The question is, when Bob tosses the coin kktimes, what's the probability that the frequency of the coin facing up is even number.
If the answer is \frac{X}{Y}YX, because the answer could be extremely large, you only need to print (X * Y^{-1}) \mod (10^9+7)(X∗Y−1)mod(109+7).
Input Format
First line an integer TT, indicates the number of test cases (T \le 100T≤100).
Then Each line has 33 integer p,q,k(1\le p,q,k \le 10^7)p,q,k(1≤p,q,k≤107) indicates the i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer.
样例输入
22 1 13 1 2
样例输出
500000004555555560
题目来源
这个可以推到一个公式
(P^n+(p-2q)^n)/(2*p^n)
这个要得到这个数要求逆元什么的,因为直接除会造成误差
当时写的那么脑残么,奇质数可以直接求
#includeusing namespace std;typedef long long ll;const ll MD=1e9+7;ll po(ll a, ll b){ ll ans=1; for(;b;a=a*a%MD,b>>=1)if(b&1)ans=ans*a%MD; return ans;}int main(){ int T; scanf("%d",&T); while(T--) { ll p,q,k; scanf("%lld%lld%lld",&p,&q,&k); printf("%lld\n",(po(p,k)+po(p-2*q,k))*po(2*po(p,k),MD-2)%MD); } return 0;}
#includeusing namespace std;const int MD=1e9+7;typedef long long LL;LL po(LL a, LL b){ LL ans=1; while(b){ if(b&1) ans=ans*a%MD; b=b/2; a=a*a%MD; } return ans;}LL la(LL a,LL b,LL &x,LL &y){ LL d; if(!b) { x=1; y=0; return a; } d=la(b,a%b,y,x); y-=a/b*x; return d;}int main(){ int T; scanf("%d",&T); while(T--) { LL p,q,k; scanf("%lld%lld%lld",&p,&q,&k); LL x,y; la(2*po(p,k),MD,x,y); x=(x%MD+MD)%MD; printf("%lld\n",(po(p,k)+po(p-2*q,k))*x%MD); } return 0;}
Define the function S(x)S(x) for xx is a positive integer. S(x)S(x) equals to the sum of all digit of the decimal expression of xx. Please find a positive integer kk that S(k*x)\%233=0S(k∗x)%233=0.
Input Format
First line an integer TT, indicates the number of test cases (T \le 100T≤100). Then Each line has a single integer x(1 \le x \le 1000000)x(1≤x≤1000000)indicates i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed 20002000. If there are more than one answer, output anyone is ok.
样例输入
11
样例输出
89999999999999999999999999
这个C的构造嘛,其实还是比较巧妙的。有输出233个9或1e6过的,1e6这个比较好想,因为每一位都得到贡献都相同,所以233次一定是233的倍数
#includeint main(){ int t,n,a=(int)1e6; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=233;i++) printf("%d",a); puts(""); }}
Given a directed graph with nnn nodes, labeled 0,1,⋯,n−10,1, \cdots, n-10,1,⋯,n−1.
For each <i,j><i, j><i,j> satisfies 0≤i<j<n0 \le i < j < n0≤i<j<n, there exists an edge from the i-th node to the j-th node, the capacity of which is iii xor jjj.
Find the maximum flow network from the 0-th node to the (n-1)-th node, modulo 100000000710000000071000000007.
Input Format
Multiple test cases (no more than 100001000010000).
In each test case, one integer in a line denotes n(2≤n≤1018)n(2 \le n \le 10^{18})n(2≤n≤1018).
Output Format
Output the maximum flow modulo 100000000710000000071000000007for each test case.
样例输入
2
样例输出
1
题目来源
#include#include #include #include #define LL long long#define mod 1000000007using namespace std;int main(){ LL a[100]={ 0},b[100]={ 0},c[100]={ 0},d[100],i; a[1]=1;b[1]=1; for(i=2;i<62;i++){ a[i]=a[i-1]*2;//每行个数 b[i]=b[i-1]+a[i];//总个数 b[i]%=mod; } d[1]=1; for(i=2;i<62;i++){ d[i]=(d[i-1]*4)%mod; } c[1]=1; for(i=2;i<62;i++){ c[i]=((2*c[i-1])%mod+(d[i]-d[i-1]+mod)%mod+mod)%mod;//每组的和 } LL n,m; while(~scanf("%lld",&n)){ LL k=0,kk=n-1; for(i=1;i<=60;i++){ if(a[i] =1;i--){ //printf("%lld - %lld\n",n,a[i]); if(n>a[i]){ sum=(sum+c[i])%mod; n-=a[i]; } //if(n<=0)break; } printf("%lld\n",(sum+m-1+mod)%mod); }}
Barty have a computer, it can do these two things.
-
Add a new string to its memory, the length of this string is even.
-
For given 444 strings a,b,c,da,b,c,da,b,c,d, find out how many strings that can be product by a+s1+b+c+s2+da+s1+b+c+s2+da+s1+b+c+s2+d, and ∣a∣+∣s1∣+∣b∣=∣c∣+∣s2∣+∣d∣|a| + |s1| + |b| = |c| + |s2| + |d|∣a∣+∣s1∣+∣b∣=∣c∣+∣s2∣+∣d∣. ∣s∣|s|∣s∣means the length of string sss, s1s1s1 and s2s2s2 can be any string, including
""
.
Please help your computer to do these things.
Input Format
Test cases begins with T(T≤5)T(T \le 5)T(T≤5).
Then TTT test cases follows.
Each test case begins with an integer Q(Q≤30000)Q(Q \le 30000)Q(Q≤30000).
Then QQQ lines,
1 s: add a new string sss to its memory.
2 a b c d: find how many strings satisfying the requirement above.
∑∣s∣+∣a∣+∣b∣+∣c∣+∣d∣≤2000000\sum |s| + |a| + |b| + |c| + |d| \le 2000000∑∣s∣+∣a∣+∣b∣+∣c∣+∣d∣≤2000000.
Output Format
For type 222 query. Output the answer in one line.
样例输入
1101 abcqaq1 abcabcqaqqaq2 ab bc qa aq2 a c q q1 abcabcqaqqwq2 ab bc qa aq2 a c q q1 abcq2 a c q q2 a b c q
样例输出
121331
题目来源
#includeusing namespace std;const int N = 1e6+10;typedef long long LL;char str[N], a[N], b[N], c[N], d[N];const LL mod = 1e9+7;const LL MD = 1313;LL *has[N], pos[N];int xlen[N];int main(){ pos[0]=1; for(int i=1;i xlen[i]/2||l3+l4>xlen[i]/2) continue; int cx=xlen[i]/2; LL x=has[i][l1]; if(x!=ans1) continue; x=(has[i][cx]-has[i][cx-l2]*pos[l2]%mod+mod)%mod; if(x!=ans2) continue; x=(has[i][cx+l3]-has[i][cx]*pos[l3]%mod+mod)%mod; if(x!=ans3) continue; x=(has[i][2*cx]-has[i][2*cx-l4]*pos[l4]%mod+mod)%mod; if(x!=ans4) continue; cnt++; } printf("%d\n",cnt); } } } return 0;}