Report on the completion of Integer Division

Source: Internet
Author: User
Tags integer division

Source: http://acm.nyist.net/JudgeOnline/problem.php? PID = 1, 571

This is a representative expression that integrates all types of integer division.

The division of N cannot exceed M. It can be written as recursion.

Define a function, void fun (INT num, int limit, int deep)

Num is the number to be divided.

The limit cannot exceed this limit.

Deep Is the depth, that is, dividing several numbers. For example, if we divide 5, the depth of the Division cannot exceed 5.

 

Int A [100]; // The Int B [5] array of the number of records; // used to record the results of each division. Int n, m; void fun (INT num, int limit, int deep) {If (num = 0) {B [0] ++; If (M = Deep) B [1] ++; int bigm = 0, jishu = 0, allno = 0; For (INT I = 0; I <deep; I ++) {if (a [I]> m) bigm = 1; if (a [I] % 2 = 0) jishu = 1; for (Int J = I + 1; j <deep; j ++) {if (I! = J & A [J] = A [I]) allno = 1 ;}} if (! Bigm) B [2] ++; If (! Jishu) B [3] ++; If (! Allno) B [4] ++; // cout <Endl;} else for (INT I = limit; I <= num; I ++) // I = Limit aims to increase the number of partitions in ascending order. {A [Deep] = I; // record the divided numbers fun (Num-I, I, deep + 1); // start recursion }}

 
Int main () {While (scanf ("% d", & N, & M )! = EOF) {for (INT I = 0; I <5; I ++) B [I] = 0; fun (n, 1, 0); For (INT I = 0; I <5; I ++) cout <B [I] <Endl; cout <Endl;} return 0 ;}

But it seems that I can't use the AC question. I don't know why .. Please kindly advise.

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.