Nishant does pretty weird stuff. Today, he wants to create a weird sequence.
According to Nishant, a sequence A of length N is called weird if:
N≥3
2⋅Ai>Ai−1+Ai+1 ∀i∈{2,3,4....,N−1}
Nishant wants to construct a long weird sequence to impress his weird friends, but there's a problem: he only knows how to count up to K, so the sequence can only contain integers in the range [1,K].
Help Nishant determine the length of the longest weird sequence he can construct using only integers from 1 to K.
Input Format
The first line contains a single integer T denoting the number of testcases. The description of T testcases follows.
The first and only line of each testcase contains a single integer K.
Output Format
For each testcase, print one line containing a single integer - the maximum length of a weird sequence which can be obtained using only integers in [1,K].
Constraints
1≤T≤105
2≤K≤109
Sample Input 1
3
3
5
1073
Sample Output 1
4
6
92
by CodeChum Admin
There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.
Go and search for the positive ones among these four!
Input
A line containing four numbers (may contain decimal places) separated by a space.
2·-4·3.6·1Output
A line containing an integer.
3write a program to print the first prime number in the given inputs .
Write a program that asks the user for a two digit number. Your program will verify that the number is two digits. If it is, display the first digit on one line and the second digit on another line. Otherwise, give a warning message to the user that the entry wasn’t correct. Only java script plz
Code a C program to read five integer values from data.txt to console; calculate and display the sum and average thereof. Use the following data to create your text file: 6,45,12,67,9
Code a C program to read five integer values from data.txt to console; calculate and display the sum and average thereof. Use the following data to create your text file: 6,45,12,67,9
Input
required to input in two sequences. first sequence is the user will input the # of items which should be greater than 1 and not be greater than 30. If the input is outside the range display "OUT OF RANGE". After validating that the range is valid, the user moves on to entering the next sequence. second sequence will require the user to input the numbers.
Out
Once all the numbers are entered, the program will simply get the largest and smallest number from the second sequence. In addition, it will also count the number of times the largest number or smallest number occurred. If the user entered the same numbers in the second sequence, the program will display the largest number and the # of times it is repeated but will display "Smallest number is the same as the largest number." for the smallest number.
In
8
8 7 6 5 4 3 2 1Out
8:1x
1:1x15
-1 -2 -5 -1 -5 -1 -5 -2 -1 -2 -1 -5 -1 -2 -1-1:7x
-5:4x
20
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9:20x
Smallest number is the same as the largest number.
Program
Create a program that will accept a character array input with a maximum array size of 30 and will check if the input contains a number.
Sample Input #1
2sHO4p
Sample Output #1
Numbers Exist:24
Sample Input #2
love
Sample Output #2
No Number
Sample Input #3
g00d morn1ng (space between characters)
Sample Output #3
Number Exist:001
Rotate Matrix Rings
Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.
Input
The first line of input will be two space-separated integers, denoting the M and N.
The next M lines will contain N space-separated integers.
The next line will contain an integer, denoting K.
Output
The output should be M*N matrix by rotating the matrix by K elements.
Explanation
Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be
4 8 12 16
3 10 6 15
2 7 11 14
1 5 9 13
Sample Input 1
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
Sample Output 1
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
Sample Input 2
3 4
1 2 3 4
10 11 12 5
9 8 7 6
2
Sample Output 2
9 10 1 2
8 11 12 3
7 6 5 4
Input
The program will accept a single text input.
Output
After the user encodes his/her text input, the program examines the text's structure which includes:
sample Input
october/15/1975
Sample Output
7:letters
6:numbers
2:special-characters
3:ooe
4:ctbr
6:151975
2://