#P8790. Fibonacci and Primes Challenge
Fibonacci and Primes Challenge
Fibonacci and Primes Challenge
This problem consists of two sub-problems:
Problem A: Fibonacci and 7
The Fibonacci sequence is defined by the recurrence (F_n = F_{n-1}+F_{n-2}) for (n\ge3) with initial values (F_1 = F_2 = 1). Consider the first (N = 202202011200) terms of the Fibonacci sequence. Count how many terms have a last digit equal to 7.
Since (N) is huge, you are expected to use the property of the Pisano period modulo 10. (Recall that the Fibonacci sequence modulo 10 repeats every 60 terms.) Let the number of occurrences of the digit 7 in one period be (c). Then the answer is (\left(\frac{N}{60}\right)\times c). After computing the count, you must convert it to a string composed solely of uppercase letters by representing the count in base 26 (with A representing 0, B representing 1, …, Z representing 25). For example, the number 8 is represented as I because 8 corresponds to the letter I (with A as 0).
Problem B: Blue's Experiment
Blue has conducted an experiment and obtained two million positive integers. Ideally, each experimental data value (x) should satisfy (10^7 \le x \le 10^8), but due to measurement errors, some values may fall in the range (10^3 \le x \le 10^{12}). It is known that over 99.99% of the data are within the expected range. Given the list of numbers, count how many of them are prime numbers.
Input Format Decision: The first token of the input is an uppercase letter that indicates which problem to solve:
- If the token is
A
, solve Problem A. There is no further input. - If the token is
B
, the next line contains an integer \(n\) (the number of data points), followed by a line with \(n\) space‐separated positive integers.
- For Problem A, output the uppercase letter string representing the base 26 conversion of the count of Fibonacci numbers (from index 1 to \(202202011200\)) whose last digit is 7.
- For Problem B, output a single integer, the count of primes among the \(n\) numbers.
Note: This is a result‐filling problem. When submitting your solution, output only the required answer as described.
inputFormat
If the first token is A, the input is:
A
If the first token is B, the input is:
B n x1 x2 x3 ... xn
where n is the number of integers and each xi is a positive integer.
outputFormat
For input A, output the result string (base-26 uppercase representation of the computed count). For input B, output a single integer representing the count of prime numbers in the given list.
sample
A
DJEZLFIU