Untitled
user_0483151
plain_text
a month ago
3.0 kB
3
Indexable
Never
#include <bits/stdc++.h> #define endl '\n' #define maxn 1005 #define TASK bai1 #define For(i,a,b) for ( int i = a; i <= b; i++ ) #define Ford(i,a,b) for ( int i = a; i >= b; i-- ) #define MOD 10000000 using namespace std; int d,m,y,yl,kq[400],aa[200], bb[200], cc[200] ,ma,sa,sb,sc; int A[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} ; int B[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} ; bool Nhuan(int x) { if ( x % 400 == 0 ) return true ; if ( x % 4 == 0 && x % 100 != 0 ) return true; return false ; } long long DayK(int x,int y) { long long t = 0; For(i,x,y) if ( Nhuan(i) ) t += 366; else t += 365 ; return t; } long long Day(int a,int b, int c, int n) { long long t = DayK(a,n-1) ; For(thang,1,c-1) if ( Nhuan(n) ) t += B[thang] ; else t += A[thang] ; t += b; return t ; } void Change(long long tong, int nam) { int t = 0,x,y; For(i,1,12) { if ( Nhuan(nam) ) t += B[i] ; else t += A[i] ; if ( t >= tong ) { y = i ; if ( Nhuan(nam) ) t-= B[i]; else t -= A[i]; break ; } } x = tong - t; cout << x << " " << y << " " << nam ; } void inp() { cin >> d >> m >> y >> yl ; } void solve() { long long a = Day(y,1,1,yl) - Day(y,d,m,y) ; long long b = DayK(y,yl-1) - Day(y,d,m,y) ; int TL = ( a / 23 ) * 23 ; int TT = ( a / 27 ) * 27 ; int CX = ( a / 33 ) * 33 ; if ( TL < a ) TL = TL + 23 - b; if ( TT < a ) TT = TT + 27 - b; if ( CX < a ) CX = CX + 33 - b; if ( Nhuan(yl) ) ma = 366; else ma = 365 ; aa[1] = TL ; bb[1] = TT ; cc[1] = CX ; For(i,2,300) { aa[i] = aa[i-1] + 23; if ( aa[i] > ma ) { sa = i - 1; break ; } } For(i,2,300) { bb[i] = bb[i-1] + 27; if ( bb[i] > ma ) { sb = i - 1; break ; } } For(i,2,300) { cc[i] = cc[i-1] + 33; if ( cc[i] > ma ) { sc = i - 1; break ; } } int dem = 0; For(i,1,sa) { For(j,1,sb) if ( aa[i] == bb[j] ) { dem++; kq[dem] = aa[i] ; } } For(i,1,sb) { For(j,1,sc) if ( bb[i] == cc[j] ) { dem++; kq[dem] = bb[i] ; } } For(i,1,sc) { For(j,1,sa) if ( cc[i] == aa[j] ) { dem++; kq[dem] = cc[i] ; } } if ( dem == 0 ) cout << "Lucky." ; else { sort(kq+1,kq+1+dem) ; For(i,1,dem) if ( kq[i] != kq[i+1] ) { Change(kq[i],yl) ; cout << endl ; } } } int main() { ios_base:: sync_with_stdio(0); cin.tie(0); if(fopen("bai1.inp","r")){ freopen("bai1.inp","r",stdin); } inp(); solve(); }
Leave a Comment