Advertisement
Anik_Akash

test1

Nov 2nd, 2020
2,015
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. //thanks God For Every Thing!
  2. //contest link:
  3.  
  4. #include<bits/stdc++.h>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <string>
  8. #include <algorithm>
  9. #include <cmath>
  10. #include <cstdio>
  11.  
  12. #define pi           acose(-1)
  13. #define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n');
  14. #define fasterio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  15. #define NL           printf("\n")
  16. #define fin          freopen("int.txt","r",stdin);
  17. #define fout         freopen("out.txt","w",stdout);
  18.  
  19.  
  20. using namespace std;
  21.  
  22. typedef long long int ll;
  23. typedef double dl;
  24.  
  25. // ---------------------- slove---------------------------//
  26.  
  27.  
  28.  
  29.  
  30. int main()
  31. {
  32.     //fin
  33.     //fout
  34.     string s;
  35.     getline(cin,s);
  36.     ll ln=0;
  37.     ln = s.length();
  38.  
  39.     int x1=0, x2=0, x3=0, chekr1=0, chekr2=0;
  40.  
  41.     int flg1=0, flg2=0, flg3=0, x=0;
  42.  
  43.     if(ln==1)
  44.     {
  45.         if(s[0] == '8')
  46.         {
  47.             printf("Yes");
  48.             NL;
  49.         }
  50.         else
  51.         {
  52.             printf("No");
  53.             NL;
  54.         }
  55.         return 0;
  56.     }
  57.     else if(ln==2)
  58.     {
  59.         x1 = s[ln-1]-48;
  60.         x2 = s[ln-2]-48;
  61.  
  62.         chekr2 = ((x2*10)+x1);
  63.         chekr1 = ((x1*10)+x2);
  64.  
  65.         if(chekr1%8==0 || chekr2%8==0)
  66.         {
  67.             printf("Yes");
  68.             NL;
  69.         }
  70.         else
  71.         {
  72.             printf("No");
  73.             NL;
  74.         }
  75.         return 0;
  76.     }
  77.  
  78.     else if(ln>=3)
  79.     {
  80.         int arr[10]={0};
  81.         for(int c=0; c<ln; c++)
  82.         {
  83.             arr[s[0]-48]++;
  84.         }
  85.         for(int i=104; i<=992; i+=8)
  86.         {
  87.             int d1, d2, d3, n;
  88.             n = i;
  89.             d1 = n%10;
  90.             n/=10;
  91.             d2 = n%10;
  92.             d3 = n/10;
  93.  
  94.             if(arr[d1]>0)
  95.             {
  96.                 arr[d1]--;
  97.                 if(arr[d2]>0)
  98.                 {
  99.                     arr[d2]--;
  100.                     if(arr[d3]>0)
  101.                     {
  102. //                        arr[d3]--;
  103. //                        if(arr[d1]>=0 && arr[d2]>=0 && arr[d3]>=0)
  104. //                        {
  105.                             printf("Yes");
  106.                             NL;
  107.                             return 0;
  108.                         //}
  109.                     }
  110.                     arr[d1]++;
  111.                     arr[d2]++;
  112.                 }
  113.             }
  114.  
  115.         }
  116.         printf("No");
  117.         NL;
  118.         return 0;
  119.     }
  120. }
  121. //author anikaksh;
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement