hdu 阿里巴巴网络赛 hdu 3951 3952 3953 3959

暂贴4条水题,其余的研究中。。。

3951

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <string.h>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <limits.h>

using namespace std;
#define LL long long
int lowbit(int t){return t&(-t);}
int countbit(int t){return (t==0)?0:(1+countbit(t&(t-1)));}
LL gcd(LL a,LL b){return (b==0)?a:gcd(b,a%b);}

#define PI acos(-1.0)
#define N  100
#define MAX INT_MAX
#define MIN INT_MIN
#define eps 1e-8
#define FRE freopen("a.txt","r",stdin)

int main(){
    int t;
    scanf("%d",&t);
    for(int ca=1;ca<=t;ca++){
        int a,b;
        scanf("%d%d",&a,&b);
        printf("Case %d: ",ca);
        if(b>=a)
        puts("first");
        else{
            if(a&1 && b==1)
            puts("first");
            else
            puts("second");
        }
    }
    return 0;
}

3952

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <string.h>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <limits.h>

using namespace std;
#define LL long long
int lowbit(int t){return t&(-t);}
int countbit(int t){return (t==0)?0:(1+countbit(t&(t-1)));}
LL gcd(LL a,LL b){return (b==0)?a:gcd(b,a%b);}

#define PI acos(-1.0)
#define N  100
#define MAX INT_MAX
#define MIN INT_MIN
#define eps 1e-8
#define FRE freopen("a.txt","r",stdin)

struct node
{
    int x[100],y[100];
    int num;
}a[100];
int maxn;
int n,m;
int st,en;
int cross(int x1,int y1,int x2,int y2,int x3,int y3){
    return (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
}

void chk(int x1,int y1,int x2,int y2){
    int i,j,k;
    int cnt=2;
    int s1,s2;
    for(i=1;i<=n;i++){//st,en其余多边形
        if(i==st || i==en)continue;
        for(j=1;j<=a[i].num;j++){
            if(j==1){s1=cross(x1,y1,x2,y2,a[i].x[j],a[i].y[j]);continue;}
            else{
                    s2=cross(x1,y1,x2,y2,a[i].x[j],a[i].y[j]);
                    if(s1*s2<=0)
                    {cnt++;break;}
                }
        }
    }
    if(cnt>maxn)maxn=cnt;
}

void gao(int x,int y){
    int i,j,k;
    for(i=1;i<=a[x].num;i++){
        for(j=1;j<=a[y].num;j++){
            chk(a[x].x[i],a[x].y[i], a[y].x[j],a[y].y[j]);
        }
    }
}

int main(){
    int t;
    scanf("%d",&t);
    int i,j,k;
    int ca;
    for(ca=1;ca<=t;ca++){
        scanf("%d",&n);
        for(i=1;i<=n;i++){
            scanf("%d",&m);
            a[i].num=m;
            for(j=1;j<=m;j++)
            scanf("%d %d",&a[i].x[j],&a[i].y[j]);
        }

        printf("Case %d: ",ca);
        if(n==1||n==2){printf("%d\n",n);continue;}

        maxn=2;
        for(i=1;i<n;i++){
            for(j=i+1;j<=n;j++){
                st=i,en=j;
                gao(st,en);
            }
        }
        printf("%d\n",maxn);
    }
    return 0;
}

3953

#include<iostream>
using namespace std;
int main()
{
    int t,c=1,i,a;
    char s1[105],s2[105];
    cin>>t;
    while(t--)
    {
        a=0;
        cin>>s1>>s2;
        for(i=0;i<strlen(s1);i++)
            a+=s1[i]-'0';
        for(i=0;i<strlen(s2);i++)
            a+=s2[i]-'0';
        printf("Case %d: ",c++);
        cout<<a<<endl;
    }
return 0;
}

3959

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <string.h>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <limits.h>

using namespace std;
#define LL long long
int lowbit(int t){return t&(-t);}
int countbit(int t){return (t==0)?0:(1+countbit(t&(t-1)));}
LL gcd(LL a,LL b){return (b==0)?a:gcd(b,a%b);}

#define PI acos(-1.0)
#define N  100
#define MAX INT_MAX
#define MIN INT_MIN
#define eps 1e-8
#define FRE freopen("a.txt","r",stdin)

int main(){
    int t;
    scanf("%d",&t);
    int i,j,k;
    for(int ca=1;ca<=t;ca++){
        int n,m;
        scanf("%d%d",&n,&m);
        int x=log((double)n)/log((double)m); //cout<<"!"<<x<<endl;
        if( pow((double)m,(double)x)!=n)x++;
        LL s1=1,s2=n;
        for(i=1;i<=x;i++)
            s1*=m;
        s1*=x;
        LL tmp=gcd(s1,n);
        if(tmp!=1){
            s1/=tmp;
            s2/=tmp;
        }
        printf("Case %d: ",ca);
        printf("%I64d/%I64d\n",s1,s2);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值