fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int quantity, instrument, counter = 1;
  6. cin >> quantity >> instrument;
  7. if ((quantity == 6 && instrument != 1) || (quantity == instrument && quantity % 2 == 0)) {
  8. cout << 0;
  9. } else if (quantity == instrument) {
  10. for (int num = 1; num % quantity != 0; num += 6) {
  11. if (num != 1 && num % quantity == 1) {
  12. cout << 0;
  13. return 0;
  14. } else {
  15. counter++;
  16. }
  17. }
  18. cout << counter;
  19. } else {
  20. for (int num = 1; num % quantity != instrument; num += 6) {
  21. if (num != 1 && num % quantity == 1) {
  22. cout << 0;
  23. return 0;
  24. } else {
  25. counter++;
  26. }
  27. }
  28. cout << counter;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4388KB
stdin
Standard input is empty
stdout
Standard output is empty