結果
| 問題 | No.3402 [Cherry Anniversary 5] Beyond Zelkova, the 5th year vista seen through the bloom of a cherry bloosom |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-12-10 10:29:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 1,214 bytes |
| 記録 | |
| コンパイル時間 | 420 ms |
| コンパイル使用メモリ | 42,848 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-10 10:29:33 |
| 合計ジャッジ時間 | 2,338 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int readymd()’:
main.cpp:41:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d%d%d", &y, &m, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:55:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%d", &qn);
| ~~~~~^~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3402.cc: No.3402 [Cherry Anniversary 5] Beyond Zelkova, the 5th year vista seen through the bloom of a cherry bloosom - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MIN_Y = 1962;
const int MAX_Y = 2025;
const int doms[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/* typedef */
/* global variables */
int yss[MAX_Y + 1];
/* subroutines */
bool leapy(int y) {
return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
int doy(int y) { return leapy(y) ? 366 : 365; }
int dom(int y, int m) { return doms[m - 1] + (m == 2 ? leapy(y) : 0); }
int ymd2t(int y, int m, int d) {
int t = yss[y];
for (int i = 1; i < m; i++) t += dom(y, i);
t += d - 1;
return t;
}
int readymd() {
int y, m, d;
scanf("%d%d%d", &y, &m, &d);
return ymd2t(y, m, d);
}
/* main */
int main() {
for (int y = MIN_Y; y < MAX_Y; y++)
yss[y + 1] = yss[y] + doy(y);
int st = readymd(), et = readymd();
int b = et - st + 1;
int qn;
scanf("%d", &qn);
while (qn--) {
int t = readymd();
int a = t - et;
if (a < b) puts("Less");
else if (a > b) puts("More");
else puts("Same");
}
return 0;
}
tnakao0123