Contest Duration: - (local time) (90 minutes) Back to Home

Submission #171360

Source Code Expand

Copy
```#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Date
{
private:
long long countDate() const
{
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
++ days[2];

long long ret = (y-1) * 365LL + (y-1) / 4 - (y-1) / 100 + (y-1) / 400;
for(int i=1; i<m; ++i)
ret += days[i];
ret += d - 1;

return ret;
}
public:
long long y;
int m, d;
Date(long long y0, int m0, int d0)
{
y = y0;
m = m0;
d = d0;
}
long long getDiff(const Date& other) const
{
return countDate() - other.countDate();
}
Date operator+(long long x) const
{
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

x += countDate();
Date ret(0, 1, 1);

long long a[] = {LLONG_MAX, 400, 100, 4, 1, 0};
int b[] = {97, 24, 1, 0};
for(int i=0; i<4; ++i){
ret.y += min(a[i] - a[i+1], x / (365 * a[i+1] + b[i]) * a[i+1]);
x -= (365 * a[i+1] + b[i]) * (ret.y % a[i] / a[i+1]);
}
++ ret.y;

if((ret.y % 4 == 0 && ret.y % 100 != 0) || ret.y % 400 == 0)
++ days[2];
while(x >= days[ret.m]){
x -= days[ret.m];
++ ret.m;
}

ret.d = (int)x + 1;

return ret;
}
bool operator<(const Date& other) const
{
return make_pair(y, make_pair(m, d)) < make_pair(other.y, make_pair(other.m, other.d));
}
};

int main()
{
int y, m, d;
cin >> y >> m >> d;
Date date(y, m, d);
cout << Date(2014, 5, 17).getDiff(date) << endl;
return 0;
}```

#### Submission Info

Submission Time 2014-05-17 21:02:20+0900 A - 経過日数 mamekin C++ (G++ 4.6.4) 100 2119 Byte AC 25 ms 924 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
 AC × 4
 AC × 24
Set Name Test Cases
Sample subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask0_sample04.txt
All subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask0_sample04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample01.txt AC 25 ms 812 KB
subtask0_sample02.txt AC 22 ms 924 KB
subtask0_sample03.txt AC 22 ms 836 KB
subtask0_sample04.txt AC 24 ms 916 KB
subtask1_01.txt AC 23 ms 804 KB
subtask1_02.txt AC 22 ms 920 KB
subtask1_03.txt AC 20 ms 916 KB
subtask1_04.txt AC 23 ms 864 KB
subtask1_05.txt AC 25 ms 844 KB
subtask1_06.txt AC 22 ms 868 KB
subtask1_07.txt AC 25 ms 856 KB
subtask1_08.txt AC 24 ms 912 KB
subtask1_09.txt AC 24 ms 916 KB
subtask1_10.txt AC 23 ms 840 KB
subtask1_11.txt AC 24 ms 916 KB
subtask1_12.txt AC 22 ms 916 KB
subtask1_13.txt AC 22 ms 916 KB
subtask1_14.txt AC 25 ms 896 KB
subtask1_15.txt AC 22 ms 792 KB
subtask1_16.txt AC 24 ms 920 KB
subtask1_17.txt AC 24 ms 916 KB
subtask1_18.txt AC 22 ms 916 KB
subtask1_19.txt AC 24 ms 908 KB
subtask1_20.txt AC 24 ms 884 KB