Uva1583 digit Generator

Source: Internet
Author: User

Because the maximum value of n given in the question is 100000, that is, the sum of the digits of N is 1 + 9 + 9 + 9 + 9 + 9 = 46,

So for any number N, you can start from the n-46 to enumerate it, check whether it meets the conditions.

# Include <stdio. h> int main () {long int N, I, S = 0, num; scanf ("% d", & num); While (Num --) {scanf ("% d", & N); {int flag = 0; for (I = n-46; I <= N; I ++) {S = I % 10 + I/10% 10 + I/100% 10 + I/1000% 10 + I/10000% 10; If (S + I = N) {flag = 1; break ;}} if (FLAG) printf ("% LD \ n", I); elseprintf ("0 \ n ");}}}

Uva1583 digit Generator

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.