結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
betweens
|
| 提出日時 | 2019-05-20 22:16:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,812 bytes |
| コンパイル時間 | 813 ms |
| コンパイル使用メモリ | 97,664 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-17 06:44:08 |
| 合計ジャッジ時間 | 1,472 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>
typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;
// Split
namespace util {
std::vector< std::string > split(std::string s, char delimiter)
{
std::vector< std::string > vs;
std::string sub;
for (auto c : s) {
if (c == delimiter) vs.push_back(sub), sub.clear();
else sub += c;
}
vs.push_back(sub);
return vs;
}
} // namespace util
// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }
// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
return os << p.first << " " << p.second;
}
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
return os;
}
template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
ll i = 0;
for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
return os;
}
void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }
ll get_day_num_of_month(ll year, ll month)
{
ll day_num = 31;
if (month == 4 || month == 6 || month == 9 || month == 11) {
day_num = 30;
} else if (month == 2) {
day_num = (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) ? 29 : 28;
}
return day_num;
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
std::string S;
std::cin >> S;
std::string y = S.substr(0, 4);
std::string m = S.substr(5, 2);
std::string d = S.substr(8, 2);
ll year = std::atoll(y.c_str());
ll month = std::atoll(m.c_str());
ll day = std::atoll(d.c_str());
ll day_num = get_day_num_of_month(year, month);
ll ans = day + 2;
if (ans > day_num) {
ans -= day_num;
year = month != 12 ? year : year + 1;
month = month != 12 ? month + 1 : 1;
}
std::cout << std::setfill('0') << std::setw(4) << year << "/";
std::cout << std::setfill('0') << std::setw(2) << month << "/";
std::cout << std::setfill('0') << std::setw(2) << ans << std::endl;
return 0;
}
betweens