Advertisement
Guest User

Nums 2007

a guest
Apr 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.21 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string a,b,c;
  8.     cin>>a>>b>>c;
  9.  
  10.     int den1=0;
  11.     den1=den1*10+(a[0]-'0');
  12.     den1=den1*10+(a[1]-'0');
  13.     bool h1=true;
  14.     if(den1>31 || den1<1) h1=false;
  15.     else{
  16.         int mesec1=0;
  17.         mesec1=mesec1*10+(a[2]-'0');
  18.         mesec1=mesec1*10+(a[3]-'0');
  19.  
  20.         if(mesec1>12 || mesec1<1) h1=0;
  21.         else{
  22.             int god1=0;
  23.             god1=god1*10+(a[4]-'0');
  24.             god1=god1*10+(a[5]-'0');
  25.             god1=god1*10+(a[6]-'0');
  26.             bool prestapna=false;
  27.             if((god1%100==0 and god1%400==0) or god1%4==0) prestapna=true;
  28.  
  29.             if(mesec1==4 or mesec1==6 or mesec1==9 or mesec1==11 and den1>30) h1=0;
  30.             else if(mesec1==2 and den1<=28 and prestapna==true) h1=0;
  31.             else if(mesec1==2 and den1>=29 and prestapna==false) h1=0;
  32.  
  33.             if(a[7]!='1' and a[7]!='6' and a[7]!='9') h1=0;
  34.  
  35.             int cnt=0;
  36.             for(int i=0;i<8;i++) cnt+=(a[i]-'0')*(a[i]-'0');
  37.  
  38.             if(cnt%7!=(a[8]-'0')) h1=0;
  39.  
  40.             if(h1==0) cout<<0<<endl;
  41.             else cout<<1<<endl;
  42.         }
  43.     }
  44.  
  45.     int den2=0;
  46.     den2=den2*10+(b[0]-'0');
  47.     den2=den2*10+(b[1]-'0');
  48.     bool h2=true;
  49.     if(den2>31 || den2<1) h2=false;
  50.     else{
  51.         int mesec1=0;
  52.         mesec1=mesec1*10+(b[2]-'0');
  53.         mesec1=mesec1*10+(b[3]-'0');
  54.  
  55.         if(mesec1>12 || mesec1<1) h2=0;
  56.         else{
  57.             int god1=0;
  58.             god1=god1*10+(b[4]-'0');
  59.             god1=god1*10+(b[5]-'0');
  60.             god1=god1*10+(b[6]-'0');
  61.             bool prestapna=false;
  62.             if((god1%100==0 and god1%400==0) or god1%4==0) prestapna=true;
  63.  
  64.             if(mesec1==4 or mesec1==6 or mesec1==9 or mesec1==11 and den2>30) h2=0;
  65.             if(mesec1==2 and den2<=28 and prestapna==true) h2=0;
  66.             if(mesec1==2 and den2>=29 and prestapna==false) h2=0;
  67.  
  68.             if(b[7]!='1' and b[7]!='6' and b[7]!='9') h2=0;
  69.  
  70.             int cnt=0;
  71.             for(int i=0;i<8;i++) cnt+=(b[i]-'0')*(b[i]-'0');
  72.  
  73.             if(cnt%7!=(b[8]-'0')) h2=0;
  74.             if(h2==0) cout<<0<<endl;
  75.             else cout<<1<<endl;
  76.         }
  77.     }
  78.  
  79.     int den3=0;
  80.     den3=den3*10+(c[0]-'0');
  81.     den3=den3*10+(c[1]-'0');
  82.     bool h3=true;
  83.     if(den3>31 || den3<1) h3=false;
  84.     else{
  85.         int mesec1=0;
  86.         mesec1=mesec1*10+(c[2]-'0');
  87.         mesec1=mesec1*10+(c[3]-'0');
  88.  
  89.         if(mesec1>12 || mesec1<1) h3=0;
  90.         else{
  91.             int god1=0;
  92.             god1=god1*10+(c[4]-'0');
  93.             god1=god1*10+(c[5]-'0');
  94.             god1=god1*10+(c[6]-'0');
  95.             bool prestapna=false;
  96.             if((god1%100==0 and god1%400==0) or god1%4==0) prestapna=true;
  97.  
  98.             if(mesec1==4 or mesec1==6 or mesec1==9 or mesec1==11 and den3>30) h3=0;
  99.             else if(mesec1==2 and den3<=28 and prestapna==true) h3=0;
  100.             else if(mesec1==2 and den3>=29 and prestapna==false) h3=0;
  101.  
  102.             if(c[7]!='1' and c[7]!='6' and c[7]!='9') h3=0;
  103.  
  104.             int cnt=0;
  105.             for(int i=0;i<8;i++) cnt+=(c[i]-'0')*(c[i]-'0');
  106.  
  107.             if(cnt%7!=(c[8]-'0')) h3=0;
  108.         }
  109.     }
  110.     if(h3==0) cout<<0<<endl;
  111.     else cout<<1<<endl;
  112.     return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement