BNU-soccer teams-01 backpack

Source: Internet
Author: User
Tags truncated

(1) features of 1 and 0:
1 is the approximate number of any integer, that is, for any integer a, there is always 1 |.
0 is a multiple of any non-zero integers. If a is 0 and A is an integer, A | 0.

(2) If the last digit of an integer is 0, 2, 4, 6, or 8, the number can be divisible by 2.
(3) If the number of an integer can be divisible by 3, the integer can be divisible by 3.
(4) If the last two digits of an integer can be divisible by four, the number can be divisible by four.
(5) If the last digit of an integer is 0 or 5, the number can be divisible by 5.
(6) If an integer can be divisible by 2 and 3, the number can be divisible by 6.
(7) If a single digit of an integer is truncated, and then two times of the single digit is subtracted from the remaining number, if the difference is a multiple of 7, the original number can be divisible by 7. If the difference is too big or it is difficult to see whether it is a multiple of 7, we need to continue the process of "tail truncation, doubling, subtraction, and verification" until we can clearly determine whether it is possible. For example, the process of judging whether 133 is a multiple of 7 is as follows: 13-3 × 2 = 7, so 133 is a multiple of 7. For example, the process of judging whether 6139 is a multiple of 7 is as follows: 613-9 × 2 = 595, 59-5 × 2 = 49, so 6139 is a multiple of 7, and so on.
(8) If the number of three digits before the end of an integer can be divisible by 8, the number can be divisible by 8.
(9) If the number of an integer can be divisible by 9, the integer can be divisible by 9.
(10) If the last digit of an integer is 0, the number can be divisible by 10.
(11) If the difference between the sum of odd-digit numbers and even-digit numbers of an integer can be divisible by 11 , Then this number can be divisible by 11. The multiple checksum of 11 can also be handled by the checksum of 7 above! The only difference in the process is that the multiples are not 2 but 1!
(12) If an integer can be divisible by 3 and 4, this number can be divisible by 12.
(13) if a single digit of an integer is truncated and four times the number of digits are added from the remaining number, if the difference is a multiple of 13, the original number can be divisible by 13. If the difference is too big or it is difficult to see whether it is a multiple of 13, we need to continue the process of "tail truncation, doubling, adding, and verification" until we can clearly determine whether it is possible.
(14) if a single digit of an integer is truncated, And then 5 times of the single digit is subtracted from the remaining number, if the difference is a multiple of 17, the original number can be divisible by 17. If the difference is too big or it is difficult to see whether it is a multiple of 17, we need to continue the process of "tail truncation, doubling, subtraction, and verification" until we can clearly determine whether it is possible.
(15) if a single digit of an integer is truncated, and a single digit is doubled from the remaining number, if the difference is a multiple of 19, the original number can be divisible by 19. If the difference is too big or it is difficult to see whether it is a multiple of 19, we need to continue the process of "tail truncation, doubling, adding, and verification" until we can clearly determine whether it is possible.
(16) if the difference between the last three digits of an integer and the first three digits of an integer can be divisible by 17, then the number can be divisible by 17.
(17) if the difference between the last three digits of an integer and the first seven times can be divisible by 19, the number can be divisible by 19.

(18) if the difference between the last four digits of an integer and the first five times can be divisible by 23 (or 29), The number can be divisible by 23.

There are also simple
The features that can be divisible by 7, 13, and 11 (actually a method) are as follows:
Divide an integer with more than four digits into two blocks between a hundred digits and a thousand digits to form two numbers. The original thousands and tens of thousands of digits on the left become one and ten digits (and so on ).
The difference between the two new numbers (a larger number minus a smaller number) does not change the feature that the original number can be divisible by 7, 11, and 13.

I know the nature of the question that can be divisible by 11. And then it keeps orz. This is DP's.Code.

 
Void solve () {sum = 0; CNT = 0; For (INT I = 1; I <= 9; ++ I) {CIN> A [I]; sum + = A [I] * I; // and CNT + = A [I]; // Several} memset (DP, 0, sizeof (DP )); DP [0] [0] = 1; for (INT x = 1; x <= 9; ++ X) {memset (use, 0, sizeof (use )); for (INT I = 0; I <CNT; ++ I) for (Int J = 0; j <= sum; ++ J) {If (DP [I] [J] & use [I] [J] <A [x]) {DP [I + 1] [J + x] = 1; use [I + 1] [J + x] = use [I] [J] + 1 ;}} int ans = 1000000; For (INT I = 0; I <CNT; ++ I) {for (Int J = 0; j <= sum; ++ J) {If (! DP [I] [J]) continue; If (ABS (Sum-j) % 11) continue; ans = min (ANS, max (ABS (CNT-I)-1, 0) ;}} if (ANS = 1000000) printf ("-1 \ n "); else printf ("% d \ n", ANS + CNT );}

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.