Decrements the maximum number of n digits to 1 (2015 Jxnu_acs algorithm Group for the first time in summer Zhou Sai)

Source: Internet
Author: User

Decrements the maximum number of n digits to 1Time limit:3000/1000ms (java/other) Memory limit:65535/32768k (Java/other) total submission (s): ACC epted Submission (s): 4Font:Times New Roman|Verdana|GeorgiaFont Size:←→Problem description, given a number n,m, decrements the number of first M of the maximum n digits to 1, for example, 2 5, printing 99 98 97 96 95. Input inputs contain multiple sets of sample samples.
For each test case, enter a number n,m (N<=10^3,1<=m<=min ((10^n) -1,10^3)). Output corresponds to each test case and prints the first m bits from the largest n digits to 1, in turn. Sample Input
1 9
Sample Output
987654321
Author Wu Yu Statistic | Submit | Back

Bored to do the other schools out of the problem,

The problem made me exhausted. Because I can't find a problem on the avionics, I don't write the question number.

#include <stdio.h> #include <math.h>int main () {int n,m,temp,x;while (scanf ("%d%d", &n,&m)!=eof) { int flag=0; if (m<10) Temp=1;else if (m<100) Temp=2;else if (m<1000) Temp=3;else if (m<10000) Temp=4;int t=1;while (m--) { for (int i=0;i<n-temp;i++) printf ("9"), X=pow (10,temp)-t;if ((n-temp)) {for (int i=1;i<temp-(int) log10 (x); i++) printf ("0");} printf ("%d\n", x); t++;}} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Decrements the maximum number of n digits to 1 (2015 Jxnu_acs algorithm Group for the first time in summer Zhou Sai)

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.