[ICPC-Hefei 2008 Online] The Luckiest Number

Luogu
IDLGP10496
Time1000ms
Memory512MB
DifficultyP5
2008数论最大公约数 gcdICPC欧拉函数
Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of only digit '8'. ## Input The input consists of multiple test cases. Each test case contains exactly one line containing L(1 ≤ L ≤ 2,000,000,000). The last test case is followed by a line containing a zero. ## Output For each test case, print a line containing the test case number( beginning with 1) followed by a integer which is the length of Bob's luckiest number. If Bob can't construct his luckiest number, print a zero. [samples]
Samples
Input #1
8
11
16
0
Output #1
Case 1: 1
Case 2: 2
Case 3: 0
API Response (JSON)
{
  "problem": {
    "name": "[ICPC-Hefei 2008 Online] The Luckiest Number",
    "description": {
      "content": "Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positiv",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P5"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10496"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positiv...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments