C: Find out 1 to 4000, the number of the number of the sum can be divisible by 4 how many?

Source: Internet
Author: User

Find out 1 to 4000, the number of numbers of the sum can be divisible by 4, such as: 745:7+4+5=16,16 can be divisible by 4, 28:2+8=10,10 not divisible by 4, 745 is such a special number, and 28 is not, ask: how many of these numbers?

Solution:

(1) For 4000,4+0+0+0=4, it is obvious that 4000 is the number satisfying the condition;

(2) for 1 to 3999, we treat each number as a 4-bit [][][][] form, the first digit [] takes 0 to 3, the latter 3 takes [0][0][0] to [9][9][9], and the sum of the 4-digit number is represented by sums:

2.1: If the latter 3 is an odd number, then the 1th place takes 1 or 3, must be able to make sum can be divisible by 4, such as sum=15,sum+1=16;sum=17,sum+3=20 can meet the conditions;

2.2: If the sum of the last 3 is an even number, may wish to use SUM1 to represent the sum of the last 3 digits, then divided into two situations, so that sum2=sum1/2, if sum2 is still even, then sum1 can be divisible by 4, the 1th position 0, can meet the conditions; if sum2 is odd, Then sum1 can not be divisible by 4, 1th position 2,sum=sum1+2 can meet the conditions;

So after 3 bit [0][0][0] to [9][9][9], always find a number in the 1th position, so that sum can be divisible by 4, because there is no number 0, so 1 to 3999 total 1000-1 = 999 numbers to meet the conditions;

In total, there are 999+1=1000 of such special figures.

This article is from the "Rock Owl" blog, please be sure to keep this source http://yaoyaolx.blog.51cto.com/10732111/1749704

C: Find out 1 to 4000, the number of the number of the sum can be divisible by 4 how many?

Related Article

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.