Guest User

Untitled

a guest
Aug 10th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define TABLE_LENGTH 3 * 5 + 1
  4.  
  5. int table[3][TABLE_LENGTH] = {
  6. { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0 },
  7. { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0 },
  8. { 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1 }
  9. };
  10.  
  11. int main()
  12. {
  13. auto mod3Num = 0, mod5Num = 0, mod7Num = 0;
  14. while (~scanf("%d%d%d", &mod3Num, &mod5Num, &mod7Num))
  15. {
  16. auto beginEntry = 0;
  17. for (auto index = table[1][mod5Num]; index < TABLE_LENGTH; index += 5)
  18. {
  19. if (table[0][index] == mod3Num)
  20. {
  21. beginEntry = index;
  22. break;
  23. }
  24. }
  25.  
  26. auto difference = (mod7Num - table[2][beginEntry] + 7) % 7;
  27. auto result = beginEntry + difference * 15;
  28. if (10 <= result && result <= 100)
  29. {
  30. printf("%d\n", result);
  31. }
  32. else
  33. {
  34. printf("No answer\n");
  35. }
  36. }
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment