turbozone88's blog

By turbozone88, history, 17 months ago, In English

Tower of Hanoi game is a famous game with discs of different sizes, with a hole in the middle, located on three stakes A, B, C.

The game begins with the state that the disks are stacked on pole A, the small disk is on the large disk, ie the smallest disk is on top, creating a cone shape. The requirement of the game is to transfer all the discs from pole A to pole C, following the following rules:

Only use 3 stakes to transfer.

Only one top disk can be moved at a time from one pole to another.

A disc is only placed on a larger disk.

In this problem, we will have n disks, numbered from 1 to n in order of increasing disk size. Initially, the disks are scattered on three poles but still satisfy the condition that the small disk is on the large disk and the goal is to convert the entire disk into a stack of disks at pole C.

Requirements: Given the state that the disks are on the poles, find a way to convert the entire disk into a stack of disks on pole C.

The first line contains the positive integer n.

The second line contains a string of n characters, the number of which is 'A' or 'B' or 'C' indicating whether disk i is on pole A or pole B or peg C.

limit : n <= 20

Input : 3 AAC

Output : 3 A->B A->C B->C

Someone help me please !

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By turbozone88, history, 18 months ago, In English
  • Vote: I like it
  • -1
  • Vote: I do not like it

By turbozone88, history, 18 months ago, In English

Calculate in $$$[L, R]$$$ how many numbers whose sum of digits and sum of squares of digits are primes ?

Limit :

  • $$$1 <= L <= R <= 10 ^ {18}$$$

  • $$$T <= 10 ^ 4$$$: is the number of queries $$$[L, R]$$$.

For example, in the $$$[1, 20]$$$ there are 4 numbers which are $$$11, 12, 14, 16$$$.

I did digit dp for each query and got TLE

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By turbozone88, history, 18 months ago, In English

Calculate in [L, R] how many numbers whose sum of digits and sum of squares of digits are primes ?

Limit :

* 1 <= L <= R <= 10 ^ 18

* T <= 10 ^ 4: is the number of queries [L, R].

For example, in the [1, 20] there are 4 numbers which are 11, 12, 14, 16.

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it