Codeforces Round #293 (Div. 2) (A, B, C, D)

Source: Internet
Author: User
Tags acos cmath

A: Simulate 26 binary additions

/************************************************************************* > File name:cf-293-a.cpp > Aut Hor:alex > Mail: [email protected] > Created time:2015 February 25 Wednesday 13:40 05 seconds ******************************* *****************************************/#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Const DoublePI =ACOs(-1);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;stringA, B;intMain () { while(Cin>> A >> B) {intLen = A.length ();intc =1; for(inti = len-1; I >=0; -I.) {if(!C) { Break; }if(A[i] = =' Z '&& c) {A[i] =' A '; }Else if(c) {++a[i]; c =0; }        }if(A >= B) {cout<<"No such string"<< Endl;Continue; }cout<< A << Endl; }return 0;}

B: Pay attention to reading the question carefully, in addition to calculate the first answer, Mark Good, then calculate the second answer

/************************************************************************* > File name:cf-293-b.cpp > Aut Hor:alex > Mail: [email protected] > Created time:2015 February 25 Wednesday 01:01 17 seconds ******************************* *****************************************/#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Const DoublePI =ACOs(-1);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;Const intN =200100;CharS[n], t[n];BOOLVis[n];intnum[ the];intMain () { while(~scanf("%s%s", S, t)) {intANS1 =0, Ans2 =0;intLen =strlen(t);memset(Num,0,sizeof(num));memset(Vis,0,sizeof(VIS)); for(inti =0; i < Len;        ++i) {++num[t[i]]; } len =strlen(s); for(inti =0; i < Len; ++i) {if(Num[s[i]) >0) {Vis[i] =1;                ++ans1;            --num[s[i]]; }        } for(inti =0; i < Len; ++i) {if(!vis[i]) {if(S[i] >=' A '&& S[i] <=' Z ')                {if(Num[s[i]-' A '+' A '] >0) {++ans2; --num[s[i]-' A '+' A ']; }                }Else{if(Num[s[i]-' A '+' A '] >0) {++ans2; --num[s[i]-' A '+' A ']; }                }            }        }printf("%d%d\n", ans1, ANS2); }return 0;}

C: Water Problem Simulation problem

/************************************************************************* > File name:cf-293-c.cpp > Aut Hor:alex > Mail: [email protected] > Created time:2015 February 25 Wednesday 14:36 58 seconds ******************************* *****************************************/#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Const DoublePI =ACOs(-1);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;Const intN =100100; vector <int>Scr[n];intArr[n];intAt[n];intOrd[n];intMain () {intN, M, K;intApp while(~scanf("%d%d%d", &n, &m, &k)) { for(inti =1; I <= N;        ++i) {scr[i].clear (); } for(inti =1; I <= N; ++i) {intpos = i/k + ((i% k)?1:0);scanf("%d", &app);            At[app] = pos; Scr[pos].push_back (APP);if(i% k) {Ord[app] = i% K-1; }Else{Ord[app] = k-1; }} LL ans =0; for(inti =1; I <= m; ++i) {scanf("%d", &app); Ans + = At[app];ints = At[app];intcur = Ord[app];if(s = =1&& cur = =0)            {Continue; }if(cur = =0)            {intSize = Scr[s-1].size ();int&a = Scr[s-1][size-1];int&b = Scr[s][cur];                At[a] = s; AT[B] = S-1; Ord[a] =0; ORD[B] = size-1;            Swap (A, b); }Else{int&a = Scr[s][cur-1];int&b = Scr[s][cur];                Ord[a] = cur; ORD[B] = cur-1;            Swap (A, b); }        }printf("%i64d\n", ans);}

D: Water problem probability DP
Set Dp[i][j] I seconds, the probability of J personal in the compartment

/************************************************************************* > File name:cf-293-d.cpp > Aut Hor:alex > Mail: [email protected] > Created time:2015 February 25 Wednesday 01:59 30 seconds ******************************* *****************************************/#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Const DoublePI =ACOs(-1);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;Doubledp[ .][ .];intN, T;DoublePintMain () { while(~scanf("%d%lf%d", &n, &p, &t)) {memset(DP,0,sizeof(DP)); dp[0][0] =1; for(inti =1; I <= t; ++i) {dp[i][0] = Dp[i-1][0] * (1-P);inte = min (n, i); for(intj =1; J <= E; ++J) {if(J < e) {Dp[i][j] = dp[i-1][j-1] * p + dp[i-1][J] * (1-P); }Else{Dp[i][j] = dp[i-1][j-1] * p + dp[i-1][J]; }            }        }DoubleAns =0; for(inti =0; I <= t;        ++i) {ans + = dp[t][i] * i; }printf("%.10f\n", ans); }return 0;}

Codeforces Round #293 (Div. 2) (A, B, C, D)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.