-
个人简介
如何用程序改变世界。
——李尧
目录:
- 观前小测Test before viewing
- 个人介绍Personal Introduction
- 码风讲解Code Style Explanation
- 附 AC鸭的罪过Attached The Crime of AC Duck
观前小测Test before viewing:
- What is your name?
- What is your wonderland.run ranking?
- How is your code style?
个人介绍Test before viewing:
- 姓名:谢奇轩
- 目前年龄:12岁
- 对代码的态度:保持中立
码风讲解Code Style Explanation:
P5440. 【XR-2】奇迹
#include<bits/stdc++.h> using namespace std; const int N=1e8+10; bool f[N]; bool d[N]; const int N2=1e7; int p[N2]; int tot=0; void Prime_sieve(int n){ f[1]=1; for(int i=2;i<=n;i++){ if(f[i]==0){ p[tot]=i; tot++; } for(int j=0;j<tot;j++){ if(i*p[j]>n){ break; } f[i*p[j]]=1; if(i%p[j]==0){ break; } } } } bool Miracle(int Date){ int year=Date/10000; int month=Date/100%100; int day=Date%100; if(f[day]==0&&f[month*100+day]==0&&f[year*10000+month*100+day]==0){ return true; }else{ return false; } } bool leap_year(int year){ return (year%4==0&&year%100!=0)||year%400==0; } bool short_month(int month){ return month==2||month==4||month==6||month==9||month==11; } int next(int Date){ int year=Date/10000; int month=Date/100%100; int day=Date%100; day++; if(leap_year(year)&&month==2&&day==30){ month++; day=1; }else if(!leap_year(year)&&month==2&&day==29){ month++; day=1; }else if(!short_month(month)&&day==32){ month++; day=1; }else if(short_month(month)&&day==31){ month++; day=1; } if(month>12){ month=1; year++; } return year*10000+month*100+day; } void Miracle_Date(){ int Date=10101; while (Date<=99991231) { if(Miracle(Date)==1){ d[Date]=1; } Date=next(Date); } } bool inspect(int Date,string s){ int year=Date/10000; int month=Date/100%100; int day=Date%100; if(leap_year(year)&&month==2&&day>=30){ return false; }else if(!leap_year(year)&&month==2&&day>=29){ return false; }else if(!short_month(month)&&day>=32){ return false; }else if(short_month(month)&&day>=31){ return false; }else if(month>12){ return false; } return true; } bool Dismantling(string s,int x){ for (int i=7;i>=0;i--) { int remainder=x%10; if(remainder!=s[i]-'0'&&s[i]!='-') { return false; } x=x/10; } return true; } int transform(string s){ int n=0; for(int i=0;i<8;i++){ n=n*10+s[i]-'0'; } return n; } int enumeration(string s){ int sum=0,mn=0,mx=0; string s1="",s2=""; for(int i=0;i<s.size();i++){ if(s[i]!='-'){ s1+=s[i]; s2+=s[i]; }else{ s1+='0'; s2+='9'; } } mn=transform(s1); mx=transform(s2); //cout<<mn<<' '<<mx; for(int i=mn;i<=mx;i++){ if(d[i]==1&&Dismantling(s,i)){ sum++; //cout<<i<<' '; } } return sum; } string s; int main(){ Prime_sieve(N); Miracle_Date(); int T; scanf("%d",&T); while(T--){ cin>>s; cout<<enumeration(s)<<endl; } return 0; }
附 AC鸭的罪过Attached The Crime of AC Duck:
(数不胜数)
- 频繁骚扰罪
- 引发暴动罪
- 欺骗AC罪
- ……
还有更多想法的点这里→AC鸭的罪过
-
最近活动
This person is lazy and didn't join any contests or homework. -
最近编写的题解
This person is lazy and didn't write any solutions. -
Stat
-
Rating