10633 Rare Easy Problem

題目原文

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

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

#include<stdio.h>

int main(void)
{
  long long input;
  int b;
  while(scanf("%lld",&input) && input)
  {
    int first = 0;
    for(b = 9; b >= 0; b--)     // 逆向思考, 以個位數 b 處理
    {
      if((input - b) % 9 == 0)     // 若 input - b 再除以 9 為整數 (因為 M 為整數)
      {
        if(first)
          putchar(' ');
        first = 1;
        printf("%lld",(input - b) / 9 * 10 + b);
      }
    }
    printf("\n");
  }
}

留言

  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

    回覆刪除

張貼留言

這個網誌中的熱門文章

離散數學筆記 — vertex cut

機率筆記 (1)

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