Advertisement
Anik_Akash

AtCoder Beginner 181D No

Nov 1st, 2020 (edited)
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.39 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.         for(int i=104; i<=992; i+=8)
  81.         {
  82.                int n=i;
  83.                 int c1, c2, c3;
  84.                 c1 = n%10;
  85.                 n/=10;
  86.                 c2 = n%10;
  87.                 c3=n/10;
  88.  
  89.                 for(int c=0; c<ln; c++)
  90.                 {
  91.                     if(s[c]-48==c1)
  92.                     {
  93.                         flg1=1;
  94.                     }
  95.  
  96.                     else if(s[c]-48==c2)
  97.                     {
  98.                         flg2=1;
  99.                     }
  100.  
  101.                     else if(s[c]-48==c3)
  102.                     {
  103.                         flg3=1;
  104.                     }
  105.  
  106.                     if(flg1==1 && flg2==1 && flg3==1)
  107.                     {
  108.                         printf("Yes");
  109.                         NL;
  110.                         return 0;
  111.                     }
  112.  
  113.                 }
  114.  
  115.         }
  116.         printf("No");
  117.         NL;
  118.         return 0;
  119.     }
  120.  
  121. }
  122.  
  123. //author anikaksh;
  124.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement