Created
October 22, 2015 19:59
-
-
Save arsho/625363d8e1155e1b2ec5 to your computer and use it in GitHub Desktop.
1006 - Hex-a-bonacci LIghtOJ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SUBMISSION TIME : 2015-10-23 01:53:21 | |
USER : Ahmedur Rahman Shovon | |
PROBLEM : 1006 - Hex-a-bonacci | |
SOURCE : JAVA | |
CPU : 0.320 | |
MEMORY : 24100 | |
VERDICT : Accepted | |
*/ | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String args[]){ | |
int caseNo=0; | |
int cases; | |
int arr[] = new int[10005]; | |
int a,b,c,d,e,f,n; | |
Scanner sc = new Scanner(System.in); | |
cases = sc.nextInt(); | |
while(caseNo != cases){ | |
a = sc.nextInt(); | |
b = sc.nextInt(); | |
c = sc.nextInt(); | |
d = sc.nextInt(); | |
e = sc.nextInt(); | |
f = sc.nextInt(); | |
n = sc.nextInt(); | |
arr[0] = a; | |
arr[1] = b; | |
arr[2] = c; | |
arr[3] = d; | |
arr[4] = e; | |
arr[5] = f; | |
for(int i=6 ;i<=n ; i++){ | |
arr[i] = ((arr[i-6]% 10000007)+(arr[i-5]% 10000007)+(arr[i-4]% 10000007)+(arr[i-3]% 10000007)+(arr[i-2]% 10000007)+(arr[i-1]% 10000007))% 10000007; | |
} | |
caseNo++; | |
System.out.println("Case "+caseNo+": "+arr[n]%10000007); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment