Guest User

ZIO 2010 P3

a guest
Jan 23rd, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int h(int x);
  5.  
  6. int f(int x){
  7.     if(x == 4) return 1;
  8.     return 3*f(((2*x+2)%11)-1);
  9. }
  10.  
  11.  
  12. int q(int x){
  13.     if(x == 7) return 1;
  14.     return f(x) + q((3*x)%10);
  15. }
  16.  
  17. int g(int x){
  18.     if(x == 0) return 1;
  19.     return (g(x-1)+f(g(x-1)) + f(x-1) + h(x-1))%10;
  20. }
  21.  
  22. int h(int x){
  23.     if(x == 0) return 1;
  24.     return (2*h(x-1) + g(x-1) + q(f(x-1)%10))%10;
  25. }
  26.  
  27.  
  28. int main() {
  29.  
  30.     // SUBTASK A :
  31.    
  32.     cout << g(4);
  33.  
  34.     // SUBTASK B :
  35.    
  36.     cout << g(7);
  37.    
  38.     // SUBTASK C :
  39.    
  40.     cout << h(6);
  41.  
  42.     return 0;
  43. }
Add Comment
Please, Sign In to add comment