HDU Alibaba Network Competition HDU 3951 3952 3953 3959

Source: Internet
Author: User
Tags acos bitset

I have posted four questions for the rest of my studies...

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 longint 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 longint 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, 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", & 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 longint 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;}

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.