24h購物| | PChome| 登入
2013-03-26 22:16:00| 人氣2,686| 回應0 | 上一篇 | 下一篇

[UVA] 10633 - Rare Easy Problem

推薦 0 收藏 0 轉貼0 訂閱站台

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;
}

台長: Morris
人氣(2,686) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][dfs] 722 - Lakes
此分類上一篇:[UVA] 494 - Kindergarten Counting Game

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文