WORMS - Play with Digit Seven


Description

A natural number x is called a good number if one or two of the next two conditions is satisfied:

  • 7 is a divisor of x.
  • 7 is a digit of x.

Task

Write a program that:

  • reads a number n from the standard input,
  • computes the number of good numbers in range [1, 10n],
  • writes the result to the standard output.

Solve the problem by at most 0.5kB of source code.

Input

The input begins with an integer t (t <= 210), the number of test cases.t test cases follow.

For each test case, the first and only line contains an integer n (1 <= n <= 500).

Output

For each test case the output consists of one line that contains the answer.

Example

Sample input:
3
1
2
1

Sample output:
1
30
1

hide comments
rangey_18o3_20: 2021-09-03 16:45:49

Do we have to print the answer mod something?

qq1010903229: 2019-12-06 06:39:05

If n=1, only 7 is valid.
If n=2, 7,14,21,28,35,42,49,56,63,70,77,84,91,98,17,27,37,47,57,67,87,97,71,72,73,74,75,76,78,79 is valid.

:D: 2011-01-08 21:52:15

You completely ignored the first condition. What about 14,21,28,... ?

Navin G V: 2011-01-08 17:36:00

Thanks i thought both condition should be satisfied.

Last edit: 2011-01-09 08:01:51

Added by:Fudan University Problem Setters
Date:2007-04-01
Time limit:1s
Source limit:512B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL GOSU JS-RHINO
Resource:Folklore, description, standard program and test data by Blue Mary