Seq
Bears have a degree of recurrence formula wherein A . 1 =. 1 . We are now given n- , request A n- .
A first line of input integer T , representative of T ( . 1 ≤ T ≤ . 1 0 0 0 0 0) set of data. Continued T lines of a digital n- ( . 1 ≤ n- ≤ . 1 0 . 1 2 ).
5 1 2 3 4 5
1 1 0 3 0
This question would have been how could not find the law, and later in reminding brother, the print out of the top 30 of A the n- discovered the law:
When n mod 6 = 1 when a1 = 1, a7 = 5, a13 = 9 ...... an = (n / 6) * 4 + 1
When n mod 6 = 2 when a2 = 1, a8 = 4, a14 = 7 ...... an = (n / 6) * 3 + 1
When n mod 6 = 3 when a3 = 0, a9 = 1, a15 = 2 ...... an = n / 6
When n mod 6 = 4 when a4 = 3, a10 = 9, a16 = 15 ...... an = n-1
When n mod 6 = 5 is a5 = 0, a11 = 1, a17 = 2 ...... an = n / 6
When n mod 6 = 0 when a6 = 3, a12 = 6, a18 = 9 ...... an = (n / 6) * 3
I use java to write specific code to refer to the following:
import java.util.Scanner; public class sep { public static void main(String[] args){ Scanner scanner=new Scanner(System.in); int t=scanner.nextInt(); while(t>0){ long n=scanner.nextLong(); if(n%6==1){ System.out.println((n/6)*4+1); } if(n%6==2){ System.out.println((n/6)*3+1); } if(n%6==3){ System.out.println(n/6); } if(n%6==4){ System.out.println((n/6)*3); } if(n%6==5){ System.out.println(n/6); } if(n%6==0){ System.out.println((n/6)*3); } t--; } } }