Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define _ ios_base:sync_with_stdio(0);cin.tie(0);
- using namespace std;
- /*** typedef ***/
- #define MEMSET_INF 127
- #define MEMSET_HALF_INF 63
- #define stream istringstream
- #define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
- #define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
- #define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
- #define INF (1<<30)
- #define PI acos(-1.0)
- #define pb push_back
- #define ppb pop_back
- #define all(x) x.begin(),x.end()
- #define mem(x,y) memset(x,y,sizeof(x))
- #define memsp(x) mem(x,MEMSET_INF)
- #define memdp(x) mem(x,-1)
- #define memca(x) mem(x,0)
- #define eps 1e-9
- #define pii pair<int,int>
- #define pmp make_pair
- #define ft first
- #define sd second
- #define vi vector<int>
- #define vpii vector<pii>
- #define si set<int>
- #define msi map<string , int >
- #define mis map<int , string >
- typedef long long i64;
- typedef unsigned long long ui64;
- /** function **/
- #define SDi(x) sf("%d",&x)
- #define SDl(x) sf("%lld",&x)
- #define SDs(x) sf("%s",x)
- #define SD2(x,y) sf("%d%d",&x,&y)
- #define SD3(x,y,z) sf("%d%d%d",&x,&y,&z)
- #define pf printf
- #define print(x) pf("%d ", x)
- #define println(x) pf("%d\n", x)
- #define sf scanf
- #define READ(f) freopen(f, "r", stdin)
- #define WRITE(f) freopen(f, "w", stdout)
- bool isLeapYear(int year) {
- return (year % 4 == 0);
- }
- map <int, int> monthTable;
- bool isFriday (string date) {
- int year = atoi( (date.substr(0, 4)).c_str() );
- int lastTwo = atoi((date.substr (2, 2)).c_str());
- int century = atoi((date.substr (0, 2)).c_str());
- int month = atoi( (date.substr(5, 2)).c_str() );
- int day = atoi( (date.substr(8, 2)).c_str() );
- int monthTableValue;
- if (isLeapYear(lastTwo) && (month == 1 || month == 2)) {
- monthTableValue = monthTable[month] - 1;
- } else {
- monthTableValue = monthTable[month];
- }
- int c = 0;
- switch (century % 4) {
- case 0:
- c = 6;
- break;
- case 1:
- c = 4;
- break;
- case 2:
- c = 2;
- break;
- case 3:
- c = 0;
- break;
- default:
- break;
- }
- int days = ( day + monthTableValue + lastTwo + int (floor(lastTwo / 4)) + c) % 7;
- if (days == 5 && day == 13)
- return true;
- return false;
- }
- int main() {
- #ifndef ONLINE_JUDGE
- READ("input.txt");
- #endif
- monthTable[1] = 0;
- monthTable[2] = 3;
- monthTable[3] = 3;
- monthTable[4] = 6;
- monthTable[5] = 1;
- monthTable[6] = 4;
- monthTable[7] = 6;
- monthTable[8] = 2;
- monthTable[9] = 5;
- monthTable[10] = 0;
- monthTable[11] = 3;
- monthTable[12] = 5;
- int tcase;
- string date;
- SDi(tcase);
- int total = 0;
- while(tcase--) {
- cin >> date;
- total += isFriday(date);
- }
- println(total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment