Last active
October 12, 2016 12:40
-
-
Save makaroni4/c77fbdafcc51f256000ffcf32c907cd7 to your computer and use it in GitHub Desktop.
Sample C program for VG
This file contains hidden or 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
#include <stdio.h> | |
long long int myfunc (long long int i, long long int cache[]) | |
{ | |
if(cache[i]) { | |
return cache[i]; | |
} | |
if (i <= 2) { | |
return i; | |
} | |
return 2*i + myfunc(i - 1, cache) + myfunc(i - 2, cache); | |
} | |
int main () { | |
long long int sum = 0; | |
int max_i = 99; | |
signed long long int myfunc_cache[max_i]; | |
for (int i = 0; i <= max_i; i++) { | |
myfunc_cache[i] = myfunc(i, myfunc_cache); | |
sum += myfunc_cache[i]; | |
printf("%d: %lld\n", i, sum); | |
} | |
printf("%s\n", "#VG"); | |
return 0; | |
} | |
This file contains hidden or 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
0: 0 | |
1: 1 | |
2: 3 | |
3: 12 | |
4: 31 | |
5: 69 | |
6: 138 | |
7: 259 | |
8: 465 | |
9: 810 | |
10: 1381 | |
11: 2319 | |
12: 3852 | |
13: 6349 | |
14: 10407 | |
15: 16992 | |
16: 27667 | |
17: 44961 | |
18: 72966 | |
19: 118303 | |
20: 191685 | |
21: 310446 | |
22: 502633 | |
23: 813627 | |
24: 1316856 | |
25: 2131129 | |
26: 3448683 | |
27: 5580564 | |
28: 9030055 | |
29: 14611485 | |
30: 23642466 | |
31: 38254939 | |
32: 61898457 | |
33: 100154514 | |
34: 162054157 | |
35: 262209927 | |
36: 424265412 | |
37: 686476741 | |
38: 1110743631 | |
39: 1797221928 | |
40: 2907967195 | |
41: 4705190841 | |
42: 7613159838 | |
43: 12318352567 | |
44: 19931514381 | |
45: 32249869014 | |
46: 52181385553 | |
47: 84431256819 | |
48: 136612644720 | |
49: 221043903985 | |
50: 357656551251 | |
51: 578700457884 | |
52: 936357011887 | |
53: 1515057472629 | |
54: 2451414487482 | |
55: 3966471963187 | |
56: 6417886453857 | |
57: 10384358420346 | |
58: 16802244877621 | |
59: 27186603301503 | |
60: 43988848182780 | |
61: 71175451488061 | |
62: 115164299674743 | |
63: 186339751166832 | |
64: 301504050845731 | |
65: 487843802016849 | |
66: 789347852866998 | |
67: 1277191654888399 | |
68: 2066539507760085 | |
69: 3343731162653310 | |
70: 5410270670418361 | |
71: 8754001833076779 | |
72: 14164272503500392 | |
73: 22918274336582569 | |
74: 37082546840088507 | |
75: 60000821176676772 | |
76: 97083368016771127 | |
77: 157084189193453901 | |
78: 254167557210231186 | |
79: 411251746403691403 | |
80: 665419303613929065 | |
81: 1076671050017627106 | |
82: 1742090353631562973 | |
83: 2818761403649197047 | |
84: 4560851757280767156 | |
85: 7379613160929971509 | |
86: -6506279155498805473 | |
87: 873334005431173688 | |
88: -4963212133198728070 | |
89: -4963071398528327630 | |
90: -4963071398528327615 | |
91: -4963071398528327614 | |
92: -4963071394103955286 | |
93: -4962930659139894359 | |
94: -4962789924469494215 | |
95: -4962649189505589073 | |
96: -4962508454835188897 | |
97: -4962367720164788721 | |
98: -4962367720164788720 | |
99: -4962226985494388520 | |
#VG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment