10633 Rare Easy Problem

題目原文

題目說明
輸入 N - M 之值,輸出可能的 N 值。

思路
設 N = 10 * a + b,輸入 input = 10 * M + b - M = 9 * M + b 。以個位數處理,最後反求 N 值。

  1. #include<stdio.h>
  2.  
  3. int main(void)
  4. {
  5. long long input;
  6. int b;
  7. while(scanf("%lld",&input) && input)
  8. {
  9. int first = 0;
  10. for(b = 9; b >= 0; b--) // 逆向思考, 以個位數 b 處理
  11. {
  12. if((input - b) % 9 == 0) // 若 input - b 再除以 9 為整數 (因為 M 為整數)
  13. {
  14. if(first)
  15. putchar(' ');
  16. first = 1;
  17. printf("%lld",(input - b) / 9 * 10 + b);
  18. }
  19. }
  20. printf("\n");
  21. }
  22. }

留言

  1. Casinos Near by Casinos Near Casinos & Resorts
    Find the nearest Casinos 광주광역 출장안마 and 사천 출장마사지 Resorts 논산 출장마사지 in Pennsylvania. Mapyro provides quick and easy to find, easy 경상북도 출장마사지 to find, and has real-time real-time 경기도 출장샵 driving directions to

    回覆刪除

張貼留言

這個網誌中的熱門文章

機率筆記 (1)

離散數學筆記 — vertex cut

機率筆記 (4) — 隨機變數