More than 2014 schools join the first game, and more than 2014 schools join the first game

Source: Internet
Author: User

More than 2014 schools join the first game, and more than 2014 schools join the first game

1001: Couple doubi

The brute force table Search Rule shows that for any p.

(1 ^ I + 2 ^ I +... + (p-1) ^ I) % p = {

Non-0, I % P-1) = 0

0, I % (p-1 )! = 0

}

Therefore, the results are clear.

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<stdlib.h>#include<cmath>using namespace std;#define eps 1e-4#define zero(x) ((fabs(x)<eps)?0:x)int main(){    int n,k;    while(~scanf("%d%d",&n,&k))    {        int x=n/(k-1);        if(x%2==0)cout<<"NO"<<endl;        else cout<<"YES"<<endl;    }    return 0;}

1004: Task

Obviously, the effect of y on the total value is much smaller than that of x.

Therefore:

Sort by y, Put y in front, then sort by x, Put x in front, then sort by attribute, and put the task in front.

Then traverse These vertices in sequence.

If the current vertex is a task:

Put the value of the current task into the set.

If the current vertex is a machine:

Find the last task in set that is less valuable than the current machine.

#include <iostream>#include<stdio.h>#include<set>#include<vector>#include<algorithm>using namespace std;#define LL long longstruct list{    int x;    int y;    int s;    int leap;    friend bool operator <(const list &a,const list &b)    {        if(a.y!=b.y)return a.y<b.y;        else if(a.x!=b.x)return a.x<b.x;        else return a.leap<b.leap;    }}node[220000];multiset<int>st;multiset<int>::iterator it;int sea(int x){    if(st.size()==0)return 0;    it=st.begin();    if(x<(*it))return 0;    it=st.lower_bound(x);    if(it==st.end())    {        it=st.end();        it--;        int ans=(*it);        st.erase(it);        return ans;    }    if((*it)==x)    {        st.erase(it);        return x;    }    it--;    int ans=(*it);    st.erase(it);    return ans;}void dos(int n){    int x=0;    LL sum=0;    st.clear();    for(int i=1;i<=n;i++)    {        if(node[i].leap==1)        {            int res=sea(node[i].s);            if(res)            {                x++;                sum+=(LL)res;            }        }        else        {            st.insert(node[i].s);        }    }    cout<<x<<" "<<sum<<endl;}int main(){    int n,m;    while(~scanf("%d%d",&n,&m))    {        for(int i=1;i<=n;i++)        {            scanf("%d%d",&node[i].x,&node[i].y);            node[i].leap=1;            node[i].s=node[i].x*500+node[i].y*2;        }        for(int i=n+1;i<=n+m;i++)        {            scanf("%d%d",&node[i].x,&node[i].y);            node[i].leap=0;            node[i].s=node[i].x*500+node[i].y*2;        }        sort(node+1,node+n+m+1);        for(int i=1;i<=n+m;i++)        {            //cout<<node[i].x<<" "<<node[i].y<<" "<<node[i].leap<<endl;        }        dos(n+m);    }    return 0;}

1005: Peter's holobby

Wh [I] [j]: the probability that the weather is I and the leaf state is j.

Ww [I] [j]: The probability that today's weather is I and tomorrow's weather is j.

St [I]: the probability that the weather on the first day is I.

The status sequence of leaves is {b1, b2. .. bn}

The probability of a weather sequence {a1, a2... an} is:

St [a1] * wh [a1] [b1] * ww [a1] [a2] * wh [a2] [b2] * ww [a2] [a3] * wh [a3] [b3] * ...... * ww [an-1] [an] * wh [an] [bn];

Because the result may be small, log is used to convert multiplication into addition.

Then it is obvious that dp is used to find the path ....

#include <iostream>#include<stdio.h>#include<set>#include<vector>#include<math.h>#include<algorithm>#include<string.h>using namespace std;#define LL long long#define INF 99999999#define eps 1e-6#define zero(x) ((fabs(x)<eps)?0:x)double wh[3][4]={    {0.6,0.2,0.15,0.05},    {0.25,0.3,0.2,0.25},    {0.05,0.10,0.35,0.5}};double ww[3][3]={    {0.5,0.375,0.125},    {0.25,0.125,0.625},    {0.25,0.375,0.375}};double st[3]={0.63,0.17,0.2};double dp[55][3];double ans[55][3];vector<int>vec;int a[110];char str[110];void dfs(int x,int y){    //cout<<y<<endl;    vec.push_back(y);    if(x==1)    {        return ;    }    for(int i=2;i>=0;i--)    {        if(zero(ans[x][y]-(ans[x-1][i]+dp[x][y]+ww[i][y]))==0)        {            dfs(x-1,i);            break;        }    }}int main(){    int T,cas,n;    scanf("%d",&T);    cas=0;    for(int i=0;i<3;i++)    {        for(int j=0;j<3;j++)        {            ww[i][j]=log(ww[i][j]);        }    }    while(T--)    {        vec.clear();        cas++;        scanf("%d",&n);        for(int i=1;i<=n;i++)        {            scanf("%s",str);            int x=strlen(str);            if(x==3)a[i]=0;            else if(x==6)a[i]=1;            else if(x==4)a[i]=2;            else if(x==5)a[i]=3;        }        memset(dp,0,sizeof(dp));        double s=0;        for(int i=1;i<=n;i++)        {            s=0;            for(int j=0;j<3;j++)            {                dp[i][j]=wh[j][a[i]];                s+=dp[i][j];            }            for(int j=0;j<3;j++)dp[i][j]=dp[i][j]/s;        }        for(int i=1;i<=n;i++)        {            for(int j=0;j<3;j++)            {                dp[i][j]=log(dp[i][j]);            }        }        for(int i=1;i<=n;i++)        {            for(int j=0;j<3;j++)ans[i][j]=-INF;        }        for(int j=0;j<3;j++)        {            ans[1][j]=dp[1][j]+log(st[j]);        }        for(int i=2;i<=n;i++)        {            for(int j=0;j<3;j++)            {                for(int k=0;k<3;k++)                {                    double ps=ans[i-1][k]+ww[k][j]+dp[i][j];                    ans[i][j]=max(ans[i][j],ps);                }            }        }        for(int i=1;i<=n;i++)        {            for(int j=0;j<3;j++)            {               // cout<<ans[i][j]<<" ";            }         //   cout<<endl;        }        double maxx=-INF;        int p=0;        for(int j=0;j<3;j++)        {            if(maxx<ans[n][j])            {                maxx=ans[n][j];                p=j;             //   cout<<maxx<<" "<<p<<endl;            }        }        dfs(n,p);        printf("Case #%d:\n",cas);        for(int i=n-1;i>=0;i--)        {            if(vec[i]==0)puts("Sunny");            if(vec[i]==1)puts("Cloudy");            if(vec[i]==2)puts("Rainy");        }    }    return 0;}
1009: Turn the pokers

Assume that all data is positive at first (the status is 0 ).

After all the operations are completed, the number of front ends is x.

There are many cases of x. For example, {x1, x2.... xk}

The result is C (m, x1) + C (m, x2) + C (m, x3) +... + C (m, xk ).

Obviously, we can know that x1, x2. .. xk are parity.

We have tested several groups of examples and we can see that x1, x2. .. xk is a continuous interval.

Then we only need to find x1 and xk.

Then, we can determine the x1 and xk after each step according to the x1 and xk in the previous step.

#include <iostream>#include<cmath>#include<algorithm>#include<cstdio>using namespace std;#define LL long long#define mod 1000000009LL jie[110000];void init(){    jie[0]=1;    jie[1]=1;    for(int i=2;i<=100000;i++)    {        jie[i]=jie[i-1]*i;        jie[i]=jie[i]%mod;    }}LL qmod(LL x,LL y){    if(y==0)return 1;    if(y==1)return x%mod;    LL ans=qmod(x,y/2);    ans=(ans*ans)%mod;    if(y%2)ans=(ans*x)%mod;    return ans;}LL dos(int n,int m){    LL ans=jie[n];    ans=(ans*qmod((jie[m]*jie[n-m])%mod,mod-2))%mod;    return ans;}int main(){    init();    int n,m,x;    while(~scanf("%d%d",&n,&m))    {        int l,r;        scanf("%d",&x);        l=r=x;        int ll,rr;        for(int i=2;i<=n;i++)        {            scanf("%d",&x);            ll=l-x;            rr=r+x;            if(ll<0)            {                if(r-x<0)ll=0+x-r;                else ll=((l-x)%2+2)%2;            }            if(rr>m)            {                if(l+x<=m)rr=m-(r+x)%2;                else rr=m-(l+x-m);            }            l=ll;            r=rr;        }        LL ans=0;        for(int i=l;i<=r;i+=2)        {            ans+=dos(m,i);            ans=ans%mod;        }        cout<<ans<<endl;    }    return 0;}
 
 
 
 
 


Why does acm C ++ display wrong answer?

You have not understood this question...
Max can be from the first to the third, or from the fifth to the tenth, you force him to start from 1 and end from k + 1, of course WA

2014 how many students are interviewed on the joint Bank of Hangzhou campus examination?

In 2014, the number of students recruited for the test on the campus of Hangzhou Union Bank was not announced. Generally, the number of students recruited for the test is one, so that three students can enter the interview. In addition, you must pass the written examination to be eligible for an interview. If there are many people, there may be two rounds of interviews. The ratio is about 1-3. For details, you can see the schedule, but the campus recruitment examination is now completed. It is an opportunity test. You can take a look at multiple choice questions, online tests, English, synthesis, and personality tests. You can also take a look at the written test materials for review.

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.