TC工作室白银局 [Cloned]

TC工作室白银局 [Cloned]

专题链接:https://vjudge.net/contest/340942#overview

A - 进制转换
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2031

#include <stdio.h>
int num[1000];
int main()
{
    int n,r,c;

    while(~scanf("%d %d",&n,&r))
    {
        if(n==0)
        {
            printf("0\n");
        }
        if(n<0)
        {
            printf("-");
            n=-n;
        }
        c=0;
        while(n)
        {
            num[c]=n%r;
            n/=r;
            c++;
        }
        for(int i=c-1;i>=0;i--)
        {
            if(num[i]>=10)
            {
                printf("%c",'A'+num[i]-10);
            }
            else
            {
                printf("%d",num[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

B - 杨辉三角
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2032
代码:

#include <stdio.h>
int main()
{
    int s = 1, h;
    int i, j;
    while(~scanf("%d", &h))
    {
        printf("1\n");
        for (i = 2; i <= h; s = 1, i++)
        {
            printf("1 ");
            for (j = 1; j <= i - 2; j++)
                printf("%d ", (s = (i - j) * s / j));
            printf("1\n");
        }
        printf("\n");
    }
    return 0;
}

C - 人见人爱A+B
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2033
代码:

#include<stdio.h>
int main()
{
    int h1,h2,m1,m2,s1,s2,h=0,m=0,s=0;
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d %d %d %d %d",&h1,&m1,&s1,&h2,&m2,&s2);
        s=(s1+s2)%60;
        m=((m1+m2)+(s1+s2)/60)%60;
        h=(h1+h2)+((m1+m2)+(s1+s2)/60)/60;
        printf("%d %d %d\n",h,m,s);
    }
    return 0;
}

D - 人见人爱A-B
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034
代码:

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int a[105];
    int b[105];
    int c[105];
    int d[105];
    int n,m,i,j,k;
    while(~scanf("%d %d",&n,&m))
    {
        memset(c,0,sizeof(c));
        if(n==0&&m==0)
        {
            break;
        }
        for(i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0; i<m; i++)
        {
            scanf("%d",&b[i]);
        }
        sort(a,a+n);
        sort(b,b+m);
        for(i=0; i<n; i++)
        {
            for(j=0; j<m; j++)
            {
                if(a[i]==b[j])
                {
                    c[a[i]]++;
                }
            }
        }
        k=0;
        for(i=0; i<n; i++)
        {
            if(c[a[i]]==0)
            {
                d[k++]=a[i];
            }
        }
        if(k==0)
        {
            printf("NULL\n");
        }
        else
        {
            for(i=0;i<k;i++)
            {
                printf("%d ",d[i]);
            }
            printf("\n");
        }
    }
    return 0;
}

E - 人见人爱A^B
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035
代码:

#include <stdio.h>
int PowerMod(int a, int b, int c)
{
    int ans = 1;
    a = a % c;
    while(b>0)
    {
        if(b % 2 == 1)
            ans = (ans * a) % c;
        b = b/2;
        a = (a * a) % c;
    }
    return ans;

}
int main()
{
    int a,b,x;
    while(~scanf("%d %d",&a,&b))
    {
        if(a==0&&b==0)
        {
            break;
        }
        x=PowerMod(a,b,1000);
        printf("%d\n",x);
    }
    return 0;
}

F - 改革春风吹满地
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2036
代码:

发布了33 篇原创文章 · 获赞 35 · 访问量 1255

猜你喜欢

转载自blog.csdn.net/qq_45856289/article/details/103940208