https://www.luogu.com.cn/problem/U629278
代码是银河,算法是罗盘,在时间的迷宫里,寻找 AC 的坐标。
RE 是常态,WA 是历练,AC 是终点,但热爱是永恒的循环。
线段树是信仰,KMP 是执念,在递归的世界里,我愿无限栈溢出。
输入是未知,输出是答案,在二分的抉择中,逼近真理的 ε。
注释是诗行,函数是乐章,愿代码的交响永远没有 TLE。
#include<bits/stdc++.h>
#define ll long long
#include<windows.h>
using namespace std;
int a[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool run(int x){
if(x%100==0)return x%400==0;
return x%4==0;
}
ll yt(int x){//x年的总秒数
return 60*60*24*(365+run(x));
}
ll mt(int x,int y){//x年y月的总秒数
if(y==2)return 60*60*24*(28+run(x));
return 60*60*24*a[y];
}
string to_str(int x){
if(x<10)return string(1,x+'0');
return to_str(x/10)+(char(x%10+'0'));
}
int main(){
string la="";
while(1){
system("cls");
ll t1,t2,t3,t4,t5,t6;
ll ti=time(0)+8*3600;
t1=1970;
while(ti>=yt(t1)){
//cout<<t1<<endl;
ti-=yt(t1);
t1++;
}
cout<<t1<<"年";
t2=1;
while(ti>=mt(t1,t2)){
ti-=mt(t1,t2);
t2++;
}
printf("%.2lld月",t2);
t3=1;
while(ti>=60*60*24){
ti-=60*60*24;
t3++;
}
printf("%.2lld日",t3);
t4=ti/3600;
t5=ti%3600/60;
t6=ti%3600%60;
printf("%.2lld时%.2lld分%.2lld秒",t4,t5,t6);
cout<<endl;
string s;
s+=to_str(t1);
if(t2<10)s+='0';
s+=to_str(t2);
if(t3<10)s+='0';
s+=to_str(t3);
if(t4<10)s+='0';
s+=to_str(t4);
if(t5<10)s+='0';
s+=to_str(t5);
if(t6<10)s+='0';
s+=to_str(t6);
//cout<<s<<endl;
set<string>ss;
for(int i=0;i<s.length()-1;i++){
if(s[i]=='3'&&s[i+1]=='7')ss.insert("37");
if(s[i]=='3'&&s[i+1]=='8')ss.insert("38");
if(s[i]=='3'&&s[i+1]=='9')ss.insert("39");
if(s[i]=='4'&&s[i+1]=='0')ss.insert("40");
if(s[i]=='4'&&s[i+1]=='1'&&i==s.length()-2)ss.insert("站到后面去");
}
bool flag=0;
for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
cout<<(*it)<<"!"<<endl;
if((*it)!="站到后面去")flag=1;
}
if(flag){
if(la!=s){
la=s;
cout<<"\a";
}
}
Sleep(200);
}
return 0;
}ll read(){
bool f=0;
ll x=0;
char ch=getchar();
while(ch<'0'||ch>'9'){
f|=(ch=='-');
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+(ch^48);
ch=getchar();
}
return f?-x:x;
}
void write(ll x){
if(x>=10)write(x/10);
putchar((x%10)|48);
}以下内容需做笔记,但还未完成:
杨表(例题abc378g)