Q1
本题要求编写程序,找出给定的n个数中的最大值及其对应的最小下标(下标从0开始)。
输入格式:
输入在第一行中给出一个正整数n(1)。第二行输入n个整数,用空格分开。
输出格式:
在一行中输出最大值及最大值的最小下标,中间用一个空格分开。
输入样例:
6 2 8 10 1 9 10
输出样例:
10 2
Notes:
1) Say that we declare a var "max" to store the max value of input on the second line. We CANNOT INIT the var with an initial value, say, 0, since the input on the second line may be positive int, 0 as well as negative int!!! If we init "max" with 0, and assume that all of the input are negative values, the output will be 0 rather than the max value in the negative input, since the init value of 'max' is 0, which is greater than all negative values.
Q2
大家都很熟悉斐波那契数列吧? 也许不会求出斐波那契数列的任意项,但这道题只需要你输出斐波那契数列第 n 项的最后一位数就可以了!
输入格式:
一个不超过100,000的正整数。
输出格式:
在一行中输出第 n 项斐波那契数的尾数。
输入样例:
7
输出样例:
3
Notes:
1) Notice that the requirement of the question is to calculate the LAST DIGIT of the fibonacci sequence, thus the sequence should be something like 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9... And we NEED NOT CALCULATE THE EXACT VALUE IN THE N_TH POSITION!!! And also my computer cannot display such big numbers when the N is pretty large, it will display "inf" instead. I didn't care much about "the last digit" at first and spent pretty much time in finding ways to accurately display very very large numbers.XD