#include <bits/stdc++.h>
using namespace std;
vector<tuple<int,int,int>> v;
int cnt = 0;
bool check(int y,int m,int d){
string sy = to_string(y);
sy = string(4-sy.size(),'0')+to_string(y);
string sm = (m/10?"":"0")+to_string(m);
string sd = (d/10?"":"0")+to_string(d);
sy = sd+sm+sy;
if(y == 2020&&m == 2&&d == 2)cout<<sy<<endl;
for(int i = 0;i<sy.size()/2;i++)if(sy[i] != sy[sy.size()-1-i])return false;
return true;
}
void add(int year){
int month = 1,day = 1;
bool leap = false;
if(year%400 == 0)leap = true;
else if(year%100 == 0)leap = false;
else if(year%4 == 0)leap = true;
else leap = false;
while(month!=13){
// cout<<year<<","<<month<<","<<day<<endl;
if(check(year,month,day))v.push_back(make_tuple(year,month,day));
day++;
if(month == 2){
if(leap&&day == 29){
day = 1;
month++;
}
else if(!leap&&day == 28){
day = 1;
month++;
}
}
else if(month == 1||month == 3||month == 5||month==7||month==8||month == 10||month == 12){
if(day == 31){
day = 1;
month++;
}
}
else{
if(day == 30){
day = 1;
month++;
}
}
}
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
auto c = clock();
for(int i = 0;i<1e4;i++){
add(i);
}
cout<<(double)(clock()-c)/CLOCKS_PER_SEC<<endl;
cout<<v.size();
cout<<"HI"<<endl;
return 0;
int t;
cin>>t;
while(t--){
string s;
cin>>s;
}
}
/*
*/
Compilation message
datum.cpp: In function 'bool check(int, int, int)':
datum.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i = 0;i<sy.size()/2;i++)if(sy[i] != sy[sy.size()-1-i])return false;
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
509 ms |
432 KB |
Output isn't correct |
2 |
Incorrect |
449 ms |
312 KB |
Output isn't correct |
3 |
Incorrect |
475 ms |
312 KB |
Output isn't correct |
4 |
Incorrect |
508 ms |
320 KB |
Output isn't correct |
5 |
Incorrect |
447 ms |
312 KB |
Output isn't correct |
6 |
Incorrect |
477 ms |
296 KB |
Output isn't correct |
7 |
Incorrect |
482 ms |
308 KB |
Output isn't correct |
8 |
Incorrect |
452 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
479 ms |
316 KB |
Output isn't correct |
10 |
Incorrect |
461 ms |
304 KB |
Output isn't correct |