T1
#include<bits/stdc++.h>
using namespace std;
int cnt=0,a[100005][3];
int q,w;
int y[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int qy[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int sy[13]={0,31,28,31,30,31,30,31,31,30,21,30,31};
void month(int now,int rem,int run)
{
if(run==1)
{
if(rem>=qy[now])
month(now+1,rem-qy[now],run);
else if(rem<qy[now])
a[cnt][1]=now,a[cnt][2]=rem+1;
}
if(run==0)
{
if(rem>=y[now])
month(now+1,rem-y[now],run);
else if(rem<y[now])
a[cnt][1]=now,a[cnt][2]=rem+1;
}
if(run==2)
{
if(rem>=sy[now])
month(now+1,rem-sy[now],run);
else if(rem<sy[now]&&now==10)
a[cnt][1]=now,a[cnt][2]=(rem<=3)?rem+1:11+rem;
else
a[cnt][1]=now,a[cnt][2]=rem+1;
}
}
void ask(int now,int rem)
{
int y;
int run=0;
if(now>1582)
{
if( (now%400==0) || ((now%4==0) && (now%100!=0)) )
y=366,run=1;
else
y=365,run=0;
}
if(0<now<1582)
{
if(now%4==0)
y=366,run=1;
else
y=365,run=0;
}
if(now<0)
{
if((now+1)%4==0)
y=366,run=1;
else
y=365,run=0;
}
if(now==1582)
{
y=355,run=2;
}
if(rem>=y)
{
if(now==-1)
ask(1,rem-y);
else
ask(now+1,rem-y);
}
if(rem<y)
{
a[++cnt][0]=now;
month(1,rem,run);
}
return;
}
int main()
{
//freopen("julian.in","r",stdin);
//freopen("julian.out","w",stdout);
cin>>q;
for(int i=1;i<=q;i++)
{
cin>>w;
ask(-4713,w);
if(a[cnt][0]>0)
cout<<a[cnt][2]<<" "<<a[cnt][1]<<" "<<a[cnt][0]<<endl;
else
cout<<a[cnt][2]<<" "<<a[cnt][1]<<" "<<-a[cnt][0]<<" BC"<<endl;
}
return 0;
}
nowcoder自测:40
T2
#include <bits/stdc++.h>
using namespace std;
int n,m,c,k,sum;
int dig[70], ned[70];
int main()
{
//freopen("zoo.in", "r", stdin);
//freopen("zoo.out", "w", stdout);
cin>>n>>m>>c>>k;
if (n <= 30)
{
long long num;
cin >> num;
int cnt = 0;
while (num)
{
if (num & 1)
dig[cnt] = 1;
cnt++;
num >>= 1;
}
}
else
{
for (int i = 1; i <= n; i++)
{
long long num;
cin>>num;
int cnt = 0;
while (num)
{
if (num & 1)
dig[cnt] = 1;
cnt++;
num >>= 1;
}
}
}
for (int i = 1; i <= m; i++)
{
int a, b;
cin>>a>>b;
ned[a] = 1;
}
for (int i = 0; i < k; i++)
if (dig[i] || (!ned[i]))
sum++;
long long ans = 1;
while (sum--)
ans <<= 1;
cout <<ans-n<<endl;;
return 0;
}
nowcoder自测:20