Advertisement
Josif_tepe

Untitled

Feb 23rd, 2024
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     long long a;
  6.     cin >> a;
  7.     if(a == 1) {
  8.         cout << 1 << endl;
  9.     }
  10.     else {
  11.         long long poceten_broj = (a - 2) / 4 * 20;
  12.         poceten_broj += 2;
  13.        
  14.         long long desetka = (a / 10) % 10;
  15.         long long cifra = a % 10;
  16.         if(desetka % 2 == 1) {
  17.             if(cifra == 0 or cifra == 4 or cifra == 8) {
  18.                 cout << poceten_broj << endl;
  19.             }
  20.             else if(cifra == 1 or cifra == 5 or cifra == 9) {
  21.                 cout << poceten_broj + 2 << endl;
  22.             }
  23.             else if(cifra == 2 or cifra == 6) {
  24.                 cout << poceten_broj + 6 << endl;
  25.             }
  26.             else {
  27.                 cout << poceten_broj + 14 << endl;
  28.             }
  29.         }
  30.         else {
  31.             if(cifra == 0 or cifra == 4 or cifra == 8) {
  32.                 cout << poceten_broj + 6 << endl;
  33.             }
  34.             else if(cifra == 1 or cifra == 5 or cifra == 9) {
  35.                 cout << poceten_broj + 14 << endl;
  36.             }
  37.             else if(cifra == 2 or cifra == 6) {
  38.                 cout << poceten_broj << endl;
  39.             }
  40.             else {
  41.                 cout << poceten_broj + 2 << endl;
  42.             }
  43.         }
  44.        
  45.     }
  46.     return 0;
  47. }
  48. // 1, 2, 4, 8, 16, 22, 24, 28, 36, 42, 44, 48, 56
  49. // 1, 2, 3, 4, 5,  6,  7,  8,  9,  10, 11, 12, 13
  50.  
  51.  
  52. // 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 44, 48, 52
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement