• C.Sum 2017 ACM-ICPC 亚洲区(西安赛区)网络赛


    题目来源:Sum

    限制:1000ms 32768K
    Define the function S(x) for xx is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please find a positive integer k that S(k∗x)%233=0.

    Input Format

    First line an integer T, indicates the number of test cases (T≤100). Then Each line has a single integer x(1≤x≤1000000) indicates i-th test case.

    Output Format

    For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed 2000. If there are more than one answer, output anyone is ok.

    样例输入
    1
    1
    样例输出

    89999999999999999999999999

    • 题目分析:
      对于一个正整数x,S(x)等于x所有位上的数字和。现在给定一个正整数x,求一个正整数k,使得S(k*x)%233==0.

    • 我的思路:
      题意不难理解,找到满足条件的k,输出就完了。可以发现k不唯一,就是题目可以接受多种正确答案,有多组解,以样例为例,把8向后移动一位同样是个解。所以这是个Special judge。
      所以,应该找特殊的解作为答案。

    下面以X==1为例,那么
    k=11111……11(233个1)是可以的
    同理x=2~9的时候,k=xxx……x(233个x)是可以的
    但是10以上的时候这样的答案就不能满足了,
    如果x=13,k如果等于k=xxx……x(233个x),那么S(k*x)%233==0就不能保证了,
    这个时候考虑结果,x=13,如果k*x=xxx……x(233个x),
    那么k * x/ x的结果就是1010……10(233个10);
    同理可以扩展到x=133(三位数),这时就是100……100(233个100);
    像1333(四位数),则k可以等于1000……1000(233个1000);
    输出结果取决于x的位数。

    完整代码:

    #include<stdio.h>
    #define MAX 2000
    int main(void)
    {
        int T, x, num;
        scanf("%d", &T);
            while (T-- > 0)
            {
                num = 0;
                scanf("%d",&x);
                while (x > 0)
                {
                    num++;
                    x /= 10;
                }
                if (num == 1)
                {
                    for (int i = 0; i < 233; i++)
                        printf("%d",x);
                }
                if (num == 2)
                {
                    for (int i = 0; i < 233; i++)
                        printf("10");
                }
                if (num == 3)
                {
                    for (int i = 0; i < 233; i++)
                        printf("100");
                }
                if (num == 4)
                {
                    for (int i = 0; i < 233; i++)
                        printf("1000");
                }
                if (num == 5)
                {
                    for (int i = 0; i < 233; i++)
                        printf("10000");
                }
                if (num == 6)
                {
                    for (int i = 0; i < 233; i++)
                        printf("100000");
                }
                printf("
    ");
            }
        return 0;
    }
    
  • 相关阅读:
    [论文阅读笔记] A Multilayered Informative Random Walk for Attributed Social Network Embedding
    [论文阅读笔记] Large-Scale Heterogeneous Feature Embedding
    [论文阅读笔记] Community-oriented attributed network embedding
    微信小程序下拉选择器(反UI的产品设计)
    浮点数
    Centos7利用rpm升级OpenSSH到openssh-8.1p1版本
    CentOS7.6使用you-get下载视频素材
    mysql5.7以后group by 报错 sql_mode=only_full_group_by的解决方法
    【MySQL】Mysql提示:Out of sort memory, consider increasing server sort buffer size
    【Python】Windows系统安装pip.whl
  • 原文地址:https://www.cnblogs.com/FlyerBird/p/9052563.html
Copyright © 2020-2023  润新知