作为一个无敌大傻逼,我 在考场上写了1.5h的T1 并且没开ll 没判1月0日。我 T3 T4 写了乱七八糟的暴力 加起来竟然只有40分。
保灵人来写题解了。/kk
T1 模拟大师。
(考场代码修改而来 有许多中文字符在机房的ubuntu下爆炸了)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL q;
LL gb=2299160,ans; //?????? -4713.1.1 ?? 2299160 ??jl???? 1582.10.4
LL mt[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
LL nf(LL y){
if(y<=1582){
if(y<0) y++;
if(y%4==0) return 366;
else return 365;
} else {
if(y%4==0&&y%100!=0||y%400==0) return 366;
else return 365;
}
}
void js(LL y,LL num){//?
for(LL i=1;i<=12;i++){
LL nw=mt[i];if(nf(y)==366&&i==2) nw++;
if(num-nw<=0){
printf("%lld %lld %lld\n",num,i,y);//Day Month Year
return;
} else num-=nw;
}
return;
}
void js2(LL y,LL num){//?
for(LL i=1;i<=12;i++){
LL nw=mt[i];if(nf(y)==366&&i==2) nw++;
if(num-nw<=0){
if(y>=0) printf("%lld %lld %lld\n",num,i,y);
else printf("%lld %lld %lld BC\n",num,i,-y);//Day Month Year
return;
} else num-=nw;
}
return;
}
void calc(LL num){//1582.10.5(????)?????jl??
//1582.1.1(????)?????jl??
num+=277;//????
//400 years a group
LL gsb=400*365+1+100-4;//1.1.1-400.12.31
if(num<=365){//1582??
js(1582,num);return;
} else num-=365;
if(num<=365){//1583
js(1583,num);return;
} else num-=365;
if(num<=366){//1584
js(1584,num);return;
} else num-=366;
//1585.1.1(????)?????num??
//1585 start
LL y=num/gsb; num-=y*gsb; y*=400; y+=1585;//before years
for(LL i=0;i<=400;i++){
LL jn=nf(y+i);
if(num<=jn){
js(y+i,num);return;
}
else num-=jn;
}
return;
}
void calc2(LL num){//-4713.1.1???????????num?? ????1.1
//400 years a group ?????jl??
LL gsb=400*365+100;//-.1.1-400.12.31
if(num<=366){
js2(-4713,num);return;
} else num-=366;
//-4712 start
LL y=num/gsb; num-=y*gsb; y*=400; y-=4712;//before years
// ???0?? ??
LL fl=0;
if(num==0) y--,num=nf(y);
if(y==0) y--,num=nf(y);
for(LL i=0;i<=400;i++){
if(y+i>=0&&!fl) y++,fl=1;
LL jn=nf(y+i);
if(num<=jn){ js2(y+i,num);return; }
else num-=jn;
}
return;
}
void solve(LL jl){
if(jl>gb){//>1582.10.4
jl-=gb;jl+=10;//1582.10.5-10.14 not have
calc(jl);//1582.10.5(????)?????jl??
} else {
jl++;
calc2(jl);//-4713.1.1????????? ????1.1
}
return;
}
int main(){
//freopen("P7075_7.in","r",stdin);
//freopen("mine.out","w",stdout);
scanf("%lld",&q);
while(q--){
LL r;scanf("%lld",&r);
solve(r);
}
return 0;
}
/*
final
*/
T2 水题
震惊 我这个蒟蒻居然没挂分。。。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;;
int n,m,c,k,cnt=0;
LL res=0;
vector<int>vec[75];
bool sl[100000010];
unsigned long long ans=0;
int main(){
//freopen("zoo.in","r",stdin);
//freopen("zoo.out","w",stdout);
scanf("%d%d%d%d",&n,&m,&c,&k);
for(int i=1;i<=n;i++){
unsigned long long a;scanf("%llu",&a); ans|=a;
}
for(int i=1;i<=m;i++){
int p,q;
scanf("%d%d",&p,&q);
vec[p].push_back(q);
}
for(int i=0;i<k;i++){
//????????
int nw=k-1-i;
if(ans&(1ull<<nw)){
for(int j=0;j<vec[nw].size();j++) sl[vec[nw][j]]=1;
}
}
for(int i=0;i<k;i++){
bool fl=1;
for(int j=0;j<vec[i].size();j++){
if(!sl[vec[i][j]]) fl=0;
// cout<<i<<" "<<j<<" "<<vec[i][j]<<endl;
}
if(fl) cnt++;//possible
}
if(cnt<63){
res=1ll<<cnt;
printf("%lld\n",res-n);
} else {
if(n==0&&cnt==64) printf("18446744073709551616\n");
else {
unsigned long long tmp=(1ull<<(cnt-1));
cout<<tmp*2-n<<endl;
}
}
return 0;
}
/*
??|???????е????o(n)
???o(k)???????Щ?????
???λ?? ????????????????????o(k)
?????????ж????????????????1??λ???????0??1 0??λ???????0??
?unsigned long long ????
*/
T3 咕
T4 咕
原文:https://www.cnblogs.com/zdsrs060330/p/13955027.html