Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <inttypes.h>
- #include <stdlib.h>
- static int64_t the_rolling_stones[] = { 39536, 36819, 31155, 89634, 79345, 63941 };
- const static int N = sizeof(the_rolling_stones)/sizeof(*the_rolling_stones);
- static void fail()
- {
- puts("Nope!");
- exit(EXIT_FAILURE);
- }
- static void led_zeppelin(int64_t c, int64_t l, int64_t k)
- {
- if ( c - k / 7 + 3 * l / 11 ) //c- (1624/7) + ((3*1441)/11) =0 ==>>> -c= - (1624/7) + ((3*1441)/11)
- fail();
- }
- static void guns_n_roses(int i, int64_t w)
- {
- if (i<N)
- {
- if ((i % 2) == 0)
- guns_n_roses(++i, w);
- else{
- guns_n_roses(i + 1, w + the_rolling_stones[i]);
- }
- }
- else if (w != 158946)//c =31052+36819+
- fail();
- }
- static void the_beatles(int b, int64_t h)
- {
- int64_t a = h;
- for(; b<N; ++b)
- {
- if (b % 2)
- continue;
- a *= the_rolling_stones[b];
- }
- if (a != 404765760) // 404765760= (8*31155*tab[4]=k) =>>> k= 404765760 / (8*31155)
- fail();
- }
- int main()
- {
- int64_t c, l, k;
- printf("Please enter the right three numbers: ");
- fflush(stdout);
- if (scanf("%" SCNd64 " %" SCNd64 " %" SCNd64, &c, &l, &k) != 3)
- fail();
- the_rolling_stones[0] = c; // -161
- the_rolling_stones[5] = l;//1441
- the_rolling_stones[4] = k;//1624
- guns_n_roses(0, 31052);
- the_beatles(1, 8);
- led_zeppelin(c, l, k);
- puts("Exactly! Good job.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement