zoukankan      html  css  js  c++  java
  • ACM 2031和2050

    好久没有上acm做题了,上星期跟绮妹说好有空带她写写程序的,所以今天自己先上来看看...

    第2031题,好久之前提交过,但一直没有成功,今天终于过了...

    #include <stdio.h>

    void getResult(int a,int b)
    {
        int n;
        if(a<b)
        {
            if(a>9)
            {
                printf("%c",'A'+a-10);
            }
            else
            {
                printf("%d",a);
            }
        }
        else
        {
            n=a%b;
            getResult(a/b,b);
            if(n>9)
            {
                printf("%c",'A'+n-10);
            }
            else
            {
                printf("%d",n);
            }
        }
    }

    int main()
    {
        int a,b;
        while(scanf("%d %d",&a,&b)!=EOF)
        {
            if(a<0)
            {
                printf("-");
                a=-a;
            }
            getResult(a,b);
            printf("\n");
        }
    }

    第2050题,说实在的,我还真无从下手,不过这种递推的题,我以后真该多练练...

    #include <stdio.h>

    int main()
    {
        int i;
        int n;
        scanf("%d",&i);
        while(i--&&scanf("%d",&n))
        {
            printf("%d\n",2*n*n-n+1);
        }
        return 0;
    }

  • 相关阅读:
    java集合Collection常用方法详解
    JavaWeb_cookie和session
    JavaWeb_Cookie
    Java中双向链表
    Java链表基础
    select函数详解及实例分析
    socket select函数的详细讲解
    记录远程用户登录日志
    MSSQL grant
    dll 中使用ADO
  • 原文地址:https://www.cnblogs.com/laizhd/p/2006850.html
Copyright © 2011-2022 走看看