Cody

# Problem 42779. GJam March 2016 IOW: Polynesiaglot Large

Solution 853557

Submitted on 19 Mar 2016 by Richard Zapor
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
tic % T 0.7 m=[1 1 4 ]; v=Polyglot(m); vexp=[5 ]; assert(isequal(vexp,v))

2   Pass
% T 0.8 m=[1 2 2 ]; v=Polyglot(m); vexp=[6 ]; assert(isequal(vexp,v))

3   Pass
% T Inf m=[43 47 500 ]; v=Polyglot(m); vexp=[671294715 ]; assert(isequal(vexp,v))

4   Pass
% T Inf m=[45 44 500 ]; v=Polyglot(m); vexp=[474858966 ]; assert(isequal(vexp,v))

5   Pass
% T 104.4 m=[1 1 500 ]; v=Polyglot(m); vexp=[523068127 ]; assert(isequal(vexp,v))

6   Pass
% T 0.3 m=[2 2 1 ]; v=Polyglot(m); vexp=[2 ]; assert(isequal(vexp,v))

7   Pass
% T Inf m=[48 41 500 ]; v=Polyglot(m); vexp=[356064865 ]; assert(isequal(vexp,v))

8   Pass
% T 1.6 m=[50 41 1 ]; v=Polyglot(m); vexp=[41 ]; assert(isequal(vexp,v))

9   Pass
% T Inf m=[41 40 500 ]; v=Polyglot(m); vexp=[396751820 ]; assert(isequal(vexp,v))

10   Pass
% T Inf m=[40 45 500 ]; v=Polyglot(m); vexp=[938256882 ]; assert(isequal(vexp,v))

11   Pass
% T Inf m=[46 44 500 ]; v=Polyglot(m); vexp=[883121986 ]; assert(isequal(vexp,v))

12   Pass
% T Inf m=[50 40 500 ]; v=Polyglot(m); vexp=[684068183 ]; assert(isequal(vexp,v))

13   Pass
% T 1.3 m=[4 3 2 ]; v=Polyglot(m); vexp=[21 ]; assert(isequal(vexp,v))

14   Pass
% T Inf m=[48 46 500 ]; v=Polyglot(m); vexp=[15068072 ]; assert(isequal(vexp,v))

15   Pass
% T Inf m=[46 47 500 ]; v=Polyglot(m); vexp=[483582780 ]; assert(isequal(vexp,v))

16   Pass
% T Inf m=[48 43 500 ]; v=Polyglot(m); vexp=[357963597 ]; assert(isequal(vexp,v))

17   Pass
% T Inf m=[40 50 500 ]; v=Polyglot(m); vexp=[722287557 ]; assert(isequal(vexp,v))

18   Pass
% T Inf m=[47 40 497 ]; v=Polyglot(m); vexp=[142264969 ]; assert(isequal(vexp,v))

19   Pass
% T Inf m=[42 45 500 ]; v=Polyglot(m); vexp=[300845428 ]; assert(isequal(vexp,v))

20   Pass
% T Inf m=[42 50 500 ]; v=Polyglot(m); vexp=[626241204 ]; assert(isequal(vexp,v))

21   Pass
% T Inf m=[50 50 499 ]; v=Polyglot(m); vexp=[244005114 ]; assert(isequal(vexp,v))

22   Pass
% T 3.1 m=[40 4 3 ]; v=Polyglot(m); vexp=[1344 ]; assert(isequal(vexp,v))

23   Pass
% T 1.6 m=[43 42 1 ]; v=Polyglot(m); vexp=[42 ]; assert(isequal(vexp,v))

24   Pass
% T Inf m=[44 49 500 ]; v=Polyglot(m); vexp=[518096485 ]; assert(isequal(vexp,v))

25   Pass
% T Inf m=[45 46 500 ]; v=Polyglot(m); vexp=[223782662 ]; assert(isequal(vexp,v))

26   Pass
% T Inf m=[49 40 500 ]; v=Polyglot(m); vexp=[678295851 ]; assert(isequal(vexp,v))

27   Pass
% T 2.2 m=[50 3 2 ]; v=Polyglot(m); vexp=[159 ]; assert(isequal(vexp,v))

28   Pass
% T 2.3 m=[48 4 2 ]; v=Polyglot(m); vexp=[208 ]; assert(isequal(vexp,v))

29   Pass
% T Inf m=[5 41 498 ]; v=Polyglot(m); vexp=[583339519 ]; assert(isequal(vexp,v))

30   Pass
% T 3.3 m=[3 43 2 ]; v=Polyglot(m); vexp=[1978 ]; assert(isequal(vexp,v))

31   Pass
% T Inf m=[41 49 500 ]; v=Polyglot(m); vexp=[707985113 ]; assert(isequal(vexp,v))

32   Pass
% T Inf m=[46 43 500 ]; v=Polyglot(m); vexp=[254325944 ]; assert(isequal(vexp,v))

33   Pass
% T 0.0 m=[2 1 1 ]; v=Polyglot(m); vexp=[1 ]; assert(isequal(vexp,v))

34   Pass
% T Inf m=[5 5 499 ]; v=Polyglot(m); vexp=[167403707 ]; assert(isequal(vexp,v))

35   Pass
% T Inf m=[48 40 500 ]; v=Polyglot(m); vexp=[687213242 ]; assert(isequal(vexp,v))

36   Pass
% T 1.7 m=[43 46 1 ]; v=Polyglot(m); vexp=[46 ]; assert(isequal(vexp,v))

37   Pass
% T Inf m=[43 4 498 ]; v=Polyglot(m); vexp=[127737869 ]; assert(isequal(vexp,v))

38   Pass
% T Inf m=[44 47 498 ]; v=Polyglot(m); vexp=[809685798 ]; assert(isequal(vexp,v))

39   Pass
% T Inf m=[41 50 500 ]; v=Polyglot(m); vexp=[701760607 ]; assert(isequal(vexp,v))

40   Pass
% T Inf m=[40 48 500 ]; v=Polyglot(m); vexp=[783408764 ]; assert(isequal(vexp,v))

41   Pass
% T Inf m=[3 40 499 ]; v=Polyglot(m); vexp=[158384704 ]; assert(isequal(vexp,v))

42   Pass
% T Inf m=[50 48 500 ]; v=Polyglot(m); vexp=[198880135 ]; assert(isequal(vexp,v))

43   Pass
% T Inf m=[49 44 497 ]; v=Polyglot(m); vexp=[539871481 ]; assert(isequal(vexp,v))

44   Pass
% T Inf m=[44 42 500 ]; v=Polyglot(m); vexp=[227201453 ]; assert(isequal(vexp,v))

45   Pass
% T Inf m=[41 47 500 ]; v=Polyglot(m); vexp=[212311056 ]; assert(isequal(vexp,v))

46   Pass
% T 254.9 m=[2 2 500 ]; v=Polyglot(m); vexp=[667073398 ]; assert(isequal(vexp,v))

47   Pass
% T Inf m=[45 50 500 ]; v=Polyglot(m); vexp=[556413734 ]; assert(isequal(vexp,v))

48   Pass
% T 5.3 m=[46 40 3 ]; v=Polyglot(m); vexp=[211200 ]; assert(isequal(vexp,v))

49   Pass
% T Inf m=[45 4 499 ]; v=Polyglot(m); vexp=[334760532 ]; assert(isequal(vexp,v))

50   Pass
% T Inf m=[40 43 500 ]; v=Polyglot(m); vexp=[328797447 ]; assert(isequal(vexp,v))

51   Pass
% T Inf m=[50 45 500 ]; v=Polyglot(m); vexp=[225964115 ]; assert(isequal(vexp,v))

52   Pass
% T Inf m=[49 42 500 ]; v=Polyglot(m); vexp=[690707538 ]; assert(isequal(vexp,v))

53   Pass
% T Inf m=[40 46 500 ]; v=Polyglot(m); vexp=[195330871 ]; assert(isequal(vexp,v))

54   Pass
% T 1.6 m=[5 4 2 ]; v=Polyglot(m); vexp=[36 ]; assert(isequal(vexp,v))

55   Pass
% T Inf m=[42 49 500 ]; v=Polyglot(m); vexp=[188049811 ]; assert(isequal(vexp,v))

56   Pass
% T 0.0 m=[1 1 1 ]; v=Polyglot(m); vexp=[1 ]; assert(isequal(vexp,v))

57   Pass
% T 218.1 m=[1 2 500 ]; v=Polyglot(m); vexp=[696656237 ]; assert(isequal(vexp,v))

58   Pass
% T Inf m=[42 40 500 ]; v=Polyglot(m); vexp=[922192442 ]; assert(isequal(vexp,v))

59   Pass
% T Inf m=[49 45 500 ]; v=Polyglot(m); vexp=[763469125 ]; assert(isequal(vexp,v))

60   Pass
% T Inf m=[50 42 500 ]; v=Polyglot(m); vexp=[328920270 ]; assert(isequal(vexp,v))

61   Pass
% T 150.3 m=[2 1 500 ]; v=Polyglot(m); vexp=[260322005 ]; assert(isequal(vexp,v))

62   Pass
% T 3.4 m=[5 49 2 ]; v=Polyglot(m); vexp=[2646 ]; assert(isequal(vexp,v))

63   Pass
% T Inf m=[47 47 500 ]; v=Polyglot(m); vexp=[237431455 ]; assert(isequal(vexp,v))

64   Pass
% T Inf m=[40 40 500 ]; v=Polyglot(m); vexp=[29203332 ]; assert(isequal(vexp,v))

65   Pass
% T Inf m=[43 41 500 ]; v=Polyglot(m); vexp=[376005947 ]; assert(isequal(vexp,v))

66   Pass
% T Inf m=[50 47 500 ]; v=Polyglot(m); vexp=[378681068 ]; assert(isequal(vexp,v))

67   Pass
% T Inf m=[47 50 500 ]; v=Polyglot(m); vexp=[795014271 ]; assert(isequal(vexp,v))

68   Pass
% T 1.6 m=[42 44 1 ]; v=Polyglot(m); vexp=[44 ]; assert(isequal(vexp,v))

69   Pass
% T Inf m=[40 41 500 ]; v=Polyglot(m); vexp=[506257932 ]; assert(isequal(vexp,v))

70   Pass
% T Inf m=[5 4 497 ]; v=Polyglot(m); vexp=[272829097 ]; assert(isequal(vexp,v))

71   Pass
% T 1.7 m=[50 50 1 ]; v=Polyglot(m); vexp=[50 ]; assert(isequal(vexp,v))

72   Pass
% T 3.7 m=[50 50 2 ]; v=Polyglot(m); vexp=[5000 ]; assert(isequal(vexp,v))

73   Pass
% T Inf m=[43 44 500 ]; v=Polyglot(m); vexp=[607981550 ]; assert(isequal(vexp,v))

74   Pass
% T Inf m=[50 49 500 ]; v=Polyglot(m); vexp=[267081842 ]; assert(isequal(vexp,v))

75   Pass
% T Inf m=[48 44 500 ]; v=Polyglot(m); vexp=[612852205 ]; assert(isequal(vexp,v))

76   Pass
% T Inf m=[45 48 500 ]; v=Polyglot(m); vexp=[652373815 ]; assert(isequal(vexp,v))

77   Pass
% T Inf m=[5 5 497 ]; v=Polyglot(m); vexp=[336290141 ]; assert(isequal(vexp,v))

78   Pass
% T Inf m=[41 42 500 ]; v=Polyglot(m); vexp=[50517743 ]; assert(isequal(vexp,v))

79   Pass
% T Inf m=[46 46 500 ]; v=Polyglot(m); vexp=[251353420 ]; assert(isequal(vexp,v))

80   Pass
% T Inf m=[45 49 500 ]; v=Polyglot(m); vexp=[66724508 ]; assert(isequal(vexp,v))

81   Pass
% T Inf m=[50 44 500 ]; v=Polyglot(m); vexp=[390526622 ]; assert(isequal(vexp,v))

82   Pass
% T Inf m=[45 47 500 ]; v=Polyglot(m); vexp=[37814577 ]; assert(isequal(vexp,v))

83   Pass
% T Inf m=[47 49 500 ]; v=Polyglot(m); vexp=[923599754 ]; assert(isequal(vexp,v))

84   Pass
% T Inf m=[44 48 500 ]; v=Polyglot(m); vexp=[872350727 ]; assert(isequal(vexp,v))

85   Pass
% T Inf m=[43 50 500 ]; v=Polyglot(m); vexp=[668567771 ]; assert(isequal(vexp,v))

86   Pass
% T Inf m=[41 4 498 ]; v=Polyglot(m); vexp=[111334900 ]; assert(isequal(vexp,v))

87   Pass
% T 3.6 m=[43 45 2 ]; v=Polyglot(m); vexp=[3960 ]; assert(isequal(vexp,v))

88   Pass
% T 1.7 m=[4 5 2 ]; v=Polyglot(m); vexp=[45 ]; assert(isequal(vexp,v))

89   Pass
% T Inf m=[40 49 500 ]; v=Polyglot(m); vexp=[281852157 ]; assert(isequal(vexp,v))

90   Pass
% T Inf m=[43 48 500 ]; v=Polyglot(m); vexp=[884129281 ]; assert(isequal(vexp,v))

91   Pass
% T Inf m=[41 48 500 ]; v=Polyglot(m); vexp=[216141546 ]; assert(isequal(vexp,v))

92   Pass
% T Inf m=[40 42 500 ]; v=Polyglot(m); vexp=[488528258 ]; assert(isequal(vexp,v))

93   Pass
% T 3.3 m=[5 42 2 ]; v=Polyglot(m); vexp=[1974 ]; assert(isequal(vexp,v))

94   Pass
% T 1.7 m=[45 45 1 ]; v=Polyglot(m); vexp=[45 ]; assert(isequal(vexp,v))

95   Pass
% T Inf m=[46 48 500 ]; v=Polyglot(m); vexp=[190132182 ]; assert(isequal(vexp,v))

96   Pass
% T 0.3 m=[1 2 1 ]; v=Polyglot(m); vexp=[2 ]; assert(isequal(vexp,v))

97   Pass
% T 3.6 m=[47 42 2 ]; v=Polyglot(m); vexp=[3738 ]; assert(isequal(vexp,v))

98   Pass
% T Inf m=[4 45 499 ]; v=Polyglot(m); vexp=[999945335 ]; assert(isequal(vexp,v))

99   Pass
% T Inf m=[44 40 500 ]; v=Polyglot(m); vexp=[53296911 ]; assert(isequal(vexp,v))

100   Pass
% T Inf m=[50 50 500 ]; v=Polyglot(m); vexp=[3178118 ]; assert(isequal(vexp,v)) toc

Elapsed time is 23.035714 seconds.

101   Pass
% Stacy992 March 12, 2016 % import java.util.*; % public class c { % public static long[][] memo; % public static long mod = 1000000007; % public static int c, v, l; % public static void main(String[] args){ % Scanner in = new Scanner(System.in); % int t = in.nextInt(); % for(int z = 1;z<=t;z++){ % c = in.nextInt(); % v = in.nextInt(); % l = in.nextInt(); % memo = new long[2][l]; % for(int i = 0;i<2;i++){ % Arrays.fill(memo[i], -1); % } % % System.out.println("Case #"+z+": "+go(0, 0)); % } % } % public static long go(int flag, int pos){ % if(pos == l){ % if(flag == 1){ % return 0; % } % return 1; % } % % if(memo[flag][pos] != -1){ % return memo[flag][pos]; % } % % long ans = 0; % ans = (ans+(go(0, pos+1)*v))%mod; % if(flag != 1){ % ans = (ans+(go(1, pos+1)*c))%mod; % } % return memo[flag][pos] = ans; % } % }

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!