2013-03-26 22:16:00Morris

[UVA] 10633 - Rare Easy Problem

Problem B
Rare Easy Problem
Input: Standard Input

Output: Standard Output

Time Limit: 1 Second

 

N is a random number, which for some reason, is at least two digits.  John Doe, a nondescript man, performs an operation on N: he chops off the last digit to form a new number M, and then finds N-M.  This excites him in a hard-to-justify way.  He then tells you N-M.  Thrilled by the fascinating back-story behind this number, you make it your life goal to figure out what N was.

 

By the way, John was later eaten by a tiger.

 

Input 

Input consists of multiple lines, one line per case.  Each line contains a single positive integer between 10 and 10^18 inclusive, giving the value of N-M.  Input is terminated by a line containing 0.

 

Output 

For each case, print one line containing the possible values of N in sorted order.  Separate consecutive numbers with a single space.

 

Sample Input                             Output for Sample Input

18

0

19 20

 


Problemsetter: Derek Kisman, Member of Elite Problemsetters' Panel

Special Thanks: Monirul Hasan, Member of Elite Problemsetters' Panel 
(Alternate Sol and Title of the Problem :))
 

“Without the constant support and, yes, competition, provided by all of the talented people here, many of us could not achieve our full potential; nor even, perhaps, realize what that potential is.”

 

-Derek Kisman

 



#include <stdio.h>

int main() {
    long long G;
    int i;
    while(scanf("%lld", &G), G) {
        int first = 0;
        for(i = 9; i >= 0; i--) {
            if((G-i)%9 == 0) {
                if(first)   putchar(' ');
                first = 1;
                printf("%lld", (G-i)/9*10+i);
            }
        }
        puts("");
    }
    return 0;
}