博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2017 ACM-ICPC 亚洲区(西安赛区)网络赛
阅读量:6931 次
发布时间:2019-06-27

本文共 6730 字,大约阅读时间需要 22 分钟。

这个西安赛区大概是我们学校打得最好的一次了,因为数学题多,而且嘛,那个I竟然就是暴力,恭喜我们学校分了个机会

    1. Coin

只看题面
  •  23.46%
  •  1000ms
  •  32768K

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)(XY1​​)mod(109​​+7).

Input Format

First line an integer TT, indicates the number of test cases (T \le 100T100).

Then Each line has 33 integer p,q,k(1\le p,q,k \le 10^7)p,q,k(1p,q,k107​​) 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)

这个要得到这个数要求逆元什么的,因为直接除会造成误差

当时写的那么脑残么,奇质数可以直接求

#include
using 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;}

 

#include
using 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;}
    1. Sum

只看题面
  •  40.09%
  •  1000ms
  •  32768K

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(kx)%233=0.

Input Format

First line an integer TT, indicates the number of test cases (T \le 100T100). Then Each line has a single integer x(1 \le x \le 1000000)x(1x1000000)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的倍数

#include
int 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(""); }}

 

    1. Maximum Flow

只看题面
  •  19.64%
  •  1000ms
  •  32768K

Given a directed graph with nnn nodes, labeled 0,1,⋯,n−10,1, \cdots, n-10,1,,n1.

For each <i,j><i, j><i,j> satisfies 0≤i<j<n0 \le i < j < n0i<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(2n1018​​).

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); }}

 

    1. Barty's Computer

只看题面
  •  22.95%
  •  4000ms
  •  524288K

Barty have a computer, it can do these two things.

  1. Add a new string to its memory, the length of this string is even.

  2. 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(T5).

Then TTT test cases follows.

Each test case begins with an integer Q(Q≤30000)Q(Q \le 30000)Q(Q30000).

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 2000000s+a+b+c+d2000000.

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

题目来源

#include 
using 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;}

 

转载于:https://www.cnblogs.com/BobHuang/p/7568192.html

你可能感兴趣的文章
防跨站脚本攻击的代码实例
查看>>
[物理学与PDEs]第1章第4节 电磁能量和电磁动量, 能量、动量守恒与转化定律 4.2 电磁动量, 动量守恒与转化定律...
查看>>
独领风骚:单例模式
查看>>
如花搞笑图片集锦(转贴)
查看>>
spring mvc DispatcherServlet详解之前传---FrameworkServlet
查看>>
Sql开发技巧
查看>>
TDictionary 是delphi用的,c++builder用起来太吃力。
查看>>
centos安装redis及php-redis扩展
查看>>
[DOM Event Learning] Section 4 事件分发和DOM事件流
查看>>
GBK、UTF8、UNICODE编码转换
查看>>
关于web页面性能测量指标与建议
查看>>
linux tar命令简介
查看>>
GTD时间管理(1)---捕获搜集
查看>>
分享web前端七款HTML5 Loading动画特效集锦
查看>>
HttpWebRequest和HttpWebResponse
查看>>
oracle10g获得Date类型字段无分,秒的解决方案!
查看>>
POJ2029——Get Many Persimmon Trees
查看>>
精彩理发头盔
查看>>
Android基调(十六)- Service:startService()、stopService()、bindService()、unbindService()加...
查看>>
linux 安装jdk
查看>>