2015.10.09周赛

CSU1525

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define LL long long
#define M 1000000007
#define INF 0x3f3f3f3f
#define RR freopen("in,txt","r",stdin)
#define WW freopen("out.txt","w",stdout)

using namespace std;

int main()
{
    int T;
    LL x,a;
    scanf("%d",&T);
    while(T--)
    {
        a=1;
        scanf("%lld",&x);
        for(int i=1;i<=x;i++)
            a=(a*i)%M;
        cout<<a-1<<endl;
    }
    return 0;
}

CSU1529

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define LL long long
#define INF 0x3f3f3f3f
#define RR freopen("in.txt","r",stdin)
#define WW freopen("out.txt","w",stdout)

using namespace std;
const int maxn = 1000010;

int dp[maxn],a[maxn];

int main()
{
    int T,n;
    scanf("%d",&T);
    while(T--)
    {

        scanf("%d",&n);
        LL sum = 0;

        int pos = 0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum += a[i];
        }
        LL sum1 = 0; //min
        LL sum2 = 0; //max
        LL ant = 0;   //res;
        LL ant1 = 0;
        for(int i=1;i<=n;i++)
        {
            sum1 += a[i];
            if(sum1 > 0)
            {
                sum1 = 0;
            }
            ant1 = min(ant1,sum1);

            sum2 += a[i];

            if(sum2 < 0)
            {
                sum2 = 0;
            }

            ant = max(ant,sum2);
        }

        ant = max(ant,sum-ant1);

        printf("%d\n",ant);


    }
    return 0;
}

CSU1530

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define LL long long
#define INF 0x3f3f3f3f
#define RR freopen("in,txt","r",stdin)
#define WW freopen("out.txt","w",stdout)

using namespace std;


int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        LL n,a,b;
        int cnt,pos;
        cin>>n>>a>>b;
        if(a % 2 || b % 2)
        {
            cout<<n<<endl;
            continue;
        }
        cnt=0;pos=0;
        for(int i=2;a%2==0;i++)
            a/=2,cnt++;
        for(int i=2;b%2==0;i*=2)
            b/=2,pos++;
        cout<<n-min(pos,cnt)<<endl;
    }
    return 0;
}

CSU1531

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define LL long long
#define INF 0x3f3f3f3f
#define RR freopen("in,txt","r",stdin)
#define WW freopen("out.txt","w",stdout)

using namespace std;

const int maxn = 300;
bool used[maxn];
int g[maxn][maxn];
int Link[maxn];
int n,m,R;

int dfs(int u)
{
    for(int v=1; v<=m; v++)
    {
        if(g[u][v] && !used[v])
        {
            used[v] = true;
            if(Link[v] == -1 || dfs(Link[v]))
            {
                Link[v] = u;
                return 1;
            }
        }
    }
    return 0;
}

int hungary()
{
    int ant = 0;
    for(int i=1; i<=n; ++i)
    {
        memset(used,false,sizeof(used));
        ant += dfs(i);
    }
    return ant;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        memset(g,false,sizeof(g));
        memset(Link,-1,sizeof(Link));
        scanf("%d%d%d",&n,&m,&R);
        double x,y;
        for(int i=0; i<R; i++)
        {
            scanf("%lf %lf",&x,&y);
            g[(int )x+1][(int )y+1] = true;
        }
        printf("%d\n",hungary());
    }
    return 0;

}

CSU1535

#include <cmath>
#include <cstdio>
#include  <iostream>
using namespace std;
int main()
{

    int n,p,w,a,b,c;
    char name[200];
    while(~scanf("%d %d",&n,&p))
    {
        for(int i=0;i<n;i++)
            scanf("%d %s",&w,name);
        a=n/3;
        b=n-a*2;
        c=b-a;
        if(c==0||c==1)
        {
            if(p>a&&p<=n-a)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else if(c==2)
        {
            if(p>a&&p<=n-a-1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值