2 Password lock (15 branch )
The tortoise gave his valuables
Password lock . There is 5 Number
Character dial . Each digital dial turns to
Dial up to increase the number 1 (9 Dial up
To 0), Dial down to reduce the number 1 (0 Dial down to get 9).
The numbers on the dial form a 5
digit . As long as the number on the dial becomes prime , The password lock will be unlocked
open . prime number ( Also known as prime number ) It can only be 1 And divisible by itself is greater than
1 The natural number of . Because the tortoise moves too slowly , He wants you to help him
How to unlock , Minimize the total number of dials .
Input
One 5 digit , Indicates the initial number of dial
Output One 5 Bitprime number , Indicates the prime number used to open the password lock
( Minimum number of dials ). If there are multiple solutions , Output the maximum number that meets the condition
The sample input 01210
Sample output 01319
3 Water accumulated in the house (15 branch )
The roof of the tortoise house is uneven , So every time it rains, it accumulates
water . In order to know whether the roof will collapse after the rainstorm , He took the shape of the roof
I gave it to you , I hope you can help him calculate the total amount of water on the roof after the rainstorm .
The turtle's roof is arranged on the same horizontal line in sequence n Width
by 1、 Height is an integer ( Give respectively ) Of tiles . For example, given
n = 5, The height of the tiles is 4, 2, 3, 5, 1, The roof can be painted on
In the grid shown in the following figure , The grey grid is tiled .
After the storm , If a square goes left and right The side extension can reach the square occupied by tiles , It just
There will be water . So the wave line grid in the figure is after the rainstorm
There will be water , The total number of ponding squares on the roof is 3.
Input Two integers n, R1, It means roof
The width of and the first term of the generated sequence . Count from left to right i (1 ≤ i ≤ n)
The height of tiles ai = Ri mod 10
Output An integer , It represents the total number of ponding squares on the roof after the rainstorm
The sample input 10, 1
Sample output 23
Data scale 1 ≤ n ≤ 100
4 Task scheduling (15 branch )
Because the tortoise moves too slowly , Yes n Tasks have exceeded the deadline
了 . Turtle treatment section i A task requires ai Unit time . from 0 moment
Start , The tortoise can choose a task , Complete it , Then start another
A mission , Go back and forth until all the tasks are completed .
As the deadline has been exceeded , Tortoise will be punished for this
penalty , The penalty value is equal to the sum of the completion time of all tasks . for example , Yes 2 individual
Tasks need 10 and 20 Unit time to complete . If you complete the task first
service 1, The penalty value is 10 + 30 = 40; If you finish the task first 2, Punish
The penalty value is 20 + 30 = 50.
Tortoise wants you to find the order of completing the task with the minimum penalty .
Input Two integers n, R1, Indicates the number of tasks and the number of builds
The first item of the column . Processing tasks i (1 ≤ i ≤ n) Time for ai = (Ri
mod 100) + 1.
Output An integer , Indicates the minimum penalty value for completing all tasks
The sample input 10, 2
Sample output 1641
Data scale
1 ≤ n ≤ 1000
5 Genome analysis (20 branch )
The tortoise got his genome , One only contains “ATCG” Four
A string of letters . The tortoise thought of the scientist and said , There are many pieces in the genome
Paragraphs are repeated many times , And this repetition is very meaningful , therefore
He wants to calculate the duplication of fragments in his genome .
Given a genome , One of the lengths is k The substring of is called a
individual “k- fragment ”. Tortoise wants you to calculate different genes in the genome k- slice
Number of segments . for example , Genome “TACAC” Of 2- The clip has “TA”,
“AC”, “CA”, “AC”, The number of different fragments is 3 individual .
Input Integers n, k, R1, Indicates the length of the genome 、 Fragment
Length and the first term generated by the sequence . Genome number i (1
≤ i
≤ n) A word
Fuzai Ri mod 4 The value of is 0, 1, 2, 3 They are
A, T, C, G
Output An integer , It means different k- Number of clips
The sample input 20, 2, 37
Sample output 10
Data scale 30% Data of n ≤ 100; 100% The data of
Satisfy 1 ≤ n ≤ 105, 1 ≤ k ≤ 10
6 Enhanced password lock (20 branch )
Tortoise got a treasure chest by chance , There is another password lock on the treasure chest .
The password lock consists of n It consists of dials , At the beginning of each dial, there is one 0 To
99 Integer between . Dial up to make the number x Turn into (x+ 1) mod 100,
Dial down to make the number x Turn into (x + 99) mod 100.
Because the password lock is in disrepair , The more times the dial is moved, the harder it is .
If a dial is moved k Time , Need to spend k2 Unit time .
The password lock is only formed by the numbers on all dials from left to
It will be solved only when the sequence of strictly increasing numbers on the right . Tortoise, please help again , seek
The minimum time to unlock the password lock .
transport Enter into Two integers n, R1, Indicates the number of dials and the number of rows
The first item of success . Count from left to right i (1 ≤ i ≤ n) Initial of dials
The number is Ri mod 100
Output An integer , Indicates the minimum time to unlock the password lock
The sample input 10, 4
Sample output 3338
Data scale
30% Data of n ≤ 3, All data meet
1 ≤ n ≤ 100