zoukankan      html  css  js  c++  java
  • [解题报告]256 Quirksome Squares

     Quirksome Squares 

    The number 3025 has a remarkable quirk: if you split its decimal representation in two strings of equal length (30 and 25) and square the sum of the numbers so obtained, you obtain the original number:

    displaymath26

    The problem is to determine all numbers with this property having a given even number of digits.

    For example, 4-digit numbers run from 0000 to 9999. Note that leading zeroes should be taken into account. This means that 0001 which is equal to tex2html_wrap_inline28 is a quirksome number of 4 digits. The number of digits may be 2,4,6 or 8. Although maxint is only 32767 and numbers of eight digits are asked for, a well-versed programmer can keep his numbers in the range of the integers. However efficiency should be given a thought.

    Input

    The input of your program is a textflle containing numbers of digits (taken from 2,4,6,8), each number on a line of its own.

    Output

    The output is a textfile consisting of lines containing the quirksome numbers (ordered according to the input numbers and for each input number in increasing order).

    Warning: Please note that the number of digits in the output is equal to the number in the corresponding input line : leading zeroes may not be suppressed.

    Sample Input

    2
    2

    Sample Output

    00
    01
    81
    00
    01
    81



    略水
    #include<stdio.h>
    int main()
    {
        int n;
        int i,j;
        while(scanf("%d",&n)!=EOF)
        {
            if(n==2)
            {
                for(i=0;i<10;i++)
                    for(j=0;j<10;j++)
                    {
                        if(i+j>=10) break;
                        if ((i+j)*(i+j)==(i*10+j)) printf("%02d\n",i*10+j);
                    }
            }
            if(n==4)
            {
                for(i=0;i<100;i++)
                    for (j=0;j<100;j++)
                    {
                        if(i+j>=100) break;
                        if((i+j)*(i+j)==(i*100+j)) printf("%04d\n",i*100+j);
                    }
            }
    
            if(n==6)
            {
                for(i=0;i<1000;i++)
                    for(j=0;j<1000;j++)
                     {
                        if(i+j>=1000) break;
                        if((i+j)*(i+j)==(i*1000+j)) printf("%06d\n",i*1000+j);
                    }
            }
    
            if(n==8)
            {
                for(i=0;i<10000;i++)
                    for(j=0;j<10000;j++)
                    {
                        if(i+j>=10000) break;
                        if((i+j)*(i+j)==(i*10000+j)) printf("%08d\n",i*10000+j);
                    }
            }
        }
        return 0;
    }
  • 相关阅读:
    SpringBoot2.x 工作流开源项目
    Nginx:终于有人把 Nginx 说清楚了,图文详解!
    MySQL8配置修改:Mysql group by this is incompatible with sql_mode=only_full_group_by
    解决错误:java.sql.SQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
    工作时使用的vim配置
    工作笔记整理
    Linux mint启用内核转储
    usleep和sleep
    gdb使用
    掩码配置为255.255.255.255
  • 原文地址:https://www.cnblogs.com/TheLaughingMan/p/2927595.html
Copyright © 2011-2022 走看看