# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
482187 |
2021-10-23T15:11:38 Z |
rainboy |
Datum (COCI20_datum) |
C |
|
32 ms |
536 KB |
#include <stdio.h>
int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int main() {
int t;
scanf("%d", &t);
while (t--) {
int d, m, y, y_;
scanf("%d.%d.%d.", &d, &m, &y);
for (y_ = y; ; y_ = (y_ + 1) % 10000) {
int d_ = (y_ % 10) * 10 + (y_ / 10 % 10);
int m_ = (y_ / 100 % 10) * 10 + (y_ / 1000);
if (m_ >= 1 && m_ <= 12
&& d_ >= 1 && d_ <= days[m_] + (m_ == 2 && y_ % 4 == 0 ? 1 : 0)
&& (y_ != y || m_ > m || m_ == m && d_ > d)) {
printf("%02d.%02d.%04d.\n", d_, m_, y_);
break;
}
}
}
return 0;
}
Compilation message
datum.c: In function 'main':
datum.c:19:39: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
19 | && (y_ != y || m_ > m || m_ == m && d_ > d)) {
| ~~~~~~~~^~~~~~~~~
datum.c:8:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
datum.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d.%d.%d.", &d, &m, &y);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
30 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
276 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
32 ms |
536 KB |
Output is correct |