708

itdef
IER
no_6
rushhhhh
RyanMoriarty
mzk
zeng9999jian
x.ac

zrq071211

//去时的飞行时间：两地时间差1+-时差
//来时的飞行时间：两地时间差2-+时差
//两式相加得    2*飞行时间 = 时间差1+时间差2
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int get_time()
{
string s;
int h1,m1,s1,h2,m2,s2,d;
getline(cin,s);
if (s[s.size()-1]!=')') s+=" (+0)";
sscanf(s.c_str(),"%d:%d:%d %d:%d:%d (+%d)",&h1,&m1,&s1,&h2,&m2,&s2,&d);
return (h2*3600+m2*60+s2+d*86400-h1*3600-m1*60-s1);

}
int main()
{
int C;
cin>>C;
string line;
getline(cin,line);//读掉回车
while (C--)
{
int time=(get_time()+get_time())/2;
int hour=time/3600,minute=time%3600/60,second=time%60;
printf ("%02d:%02d:%02d\n",hour,minute,second);
}
return 0;
}


//因为答案都在19600101到20591231之间，所以我们先直接枚举日期然后再看这个日期
//能不能由给的日期通过变换得到，这样既保证答案从早到晚又不会漏掉情况
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(int x)
{
int month=x/100%100,day=x%100,year=x/1000;
if (day==0||month>13||month==0)
return false;
if (month!=2&&day>days[month])
return false;
if (month==2)
{
if (year%100!=0&&year%4==0||year%400==0)
{
if (day>29)
return false;
}
else
{
if (day>28)
return false;
}
}
return true;
}
int main()
{
int a,b,c;
scanf("%d/%d/%d",&a,&b,&c);
for (int i=19600101;i<=20591231;i++)
{
if (check(i))
{
int year=i/10000,month=i/100%100,day=i%100;
if (year%100==a&&month==b&&day==c||
year%100==c&&month==a&&day==b||
year%100==c&&month==b&&day==a)
printf ("%d-%02d-%02d\n",year,month,day);
}
}
return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int w,m,n;
cin>>w>>m>>n;
m--,n--;
int x1,x2,y1,y2;
x1=m/w;
x2=n/w;
if (x1%2==1)
y1=w-m%w-1;
else
y1=m%w;
if (x2%2==1)
y2=w-n%w-1;
else
y2=n%w;
cout<<abs(x1-x2)+abs(y1-y2);
return 0;
}


#include<iostream>
using namespace std;
const int N=1e5+10;
long long a[N],res=0,temp[N];
void meger_sort(int l,int r)
{
if (l>=r) return ;
int mid=(l+r)/2;
meger_sort(l,mid),meger_sort(mid+1,r);
int i=l,j=mid+1,k=0;
while (i<=mid&&j<=r)
{
if (a[i]<=a[j])
temp[k++]=a[i++];
else
{
temp[k++]=a[j++];
res+=mid-i+1;
}

}
while (i<=mid) temp[k++]=a[i++];
while (j<=r) temp[k++]=a[j++];
for (int i=l,j=0;i<=r;i++,j++)
a[i]=temp[j];
}
int main()
{
int n;
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i];
meger_sort(0,n-1);
cout<<res;
return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int a[1010][1010];
int main()
{
int w,m,n,x=1;
cin>>w>>m>>n;
for (int i=1;i<1001;i++)
{
if (i%2==1)
{
for (int j=1;j<=w;j++)
a[i][j]=x++;
}
else
{
for (int j=w;j>=1;j--)
a[i][j]=x++;
}
}
int x1,y1,x2,y2;
for (int i=1;i<1001;i++)
for (int j=1;j<1001;j++)
{
if (a[i][j]==m)
x1=i,y1=j;
if (a[i][j]==n)
x2=i,y2=j;
}
cout<<abs(x1-x2)+abs(y1-y2);
return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(int date)
{
int year=date/10000;
int month=date/100%100;
int day=date%100;
if (month==0||month>12||day==0)
return false;
if (month!=2&&day>days[month])
return false;
if (month==2)
{
if ((year%100!=0&&year%4==0)||year%400==0)
{
if (day>29)
return false;
}
else
{
if (day>28)
return false;
}
}
return true;
}
int main()
{
int date1,date2,res=0;
cin>>date1>>date2;
for (int i=1000;i<10000;i++)
{
int x=i,y=i;
while (x)
{
y=y*10+x%10;
x/=10;
}
if (y>=date1&&y<=date2)
if (check(y))
res++;
}
//10000101
//99991231
cout<<res;
return 0;
}


#include<iostream>
using namespace std;
const int N=1e4+10;
int a[N];
int main()
{
int n,res=0;
cin>>n;
for (int i=0; i<n;i++)
cin>>a[i];
for (int i=0;i<n;i++)
{
int maxn=-N,minn=N;
for (int j=i;j<n;j++)
{
if (a[j]>maxn) maxn=a[j];
if (a[j]<minn) minn=a[j];
if (maxn-minn==j-i)
res++;
}
}
cout<<res;
return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1e5+10;
int a[N],b[N],c[N];
int sa[N],sc[N];
int cnt[N],s[N];
int main()
{
int n;
cin>>n;
//读入
for (int i=0;i<n;i++) cin>>a[i],a[i]++;//求前缀和的时候s[0]=0,所以把数都往后挪一
for (int i=0;i<n;i++) cin>>b[i],b[i]++;
for (int i=0;i<n;i++) cin>>c[i],c[i]++;
//求在a[]中小于b[i]的个数
for (int i=0;i<n;i++) cnt[a[i]]++;
for (int i=1;i<=N;i++) s[i]=s[i-1]+cnt[i];
for (int i=0;i<n;i++)  sa[i]=s[b[i]-1];
//求在c[]中大于b[i]的个数
memset(s,0,sizeof s);
memset(cnt,0,sizeof cnt);
for (int i=0;i<n;i++) cnt[c[i]]++;
for (int i=0;i<=N;i++) s[i]=s[i-1]+cnt[i];
for (int i=0;i<n;i++) sc[i]=s[N-1]-s[b[i]];
long long res=0;
for (int i=0;i<n;i++)
res+=(long long) sa[i]*sc[i];
cout<<res;
return 0;
}


#include<iostream>
using namespace std;
const int N=100010;
int a[N],temp[N];
void merge_sort(int l,int r)
{
if (l>=r) return ;
int mid=(l+r)/2;
merge_sort(l,mid),merge_sort(mid+1,r);
int k=0,i=l,j=mid+1;
while (i<=mid&&j<=r)
{
if (a[i]<=a[j])
temp[k++]=a[i++];
else
temp[k++]=a[j++];
}
while (i<=mid) temp[k++]=a[i++];
while (j<=r) temp[k++]=a[j++];
for (i=l,j=0;i<=r;i++,j++)
a[i]=temp[j];
}
int main()
{
int n;
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i];
merge_sort(0,n-1);
for (int i=0;i<n;i++)
cout<<a[i]<<' ';
return 0;
}


#include<iostream>
using namespace std;
{
while (x!=0)
{
if (x%10==2||x%10==0||x%10==1||x%10==9)
return true;
else
x/=10;
}
return false;
}
int main()
{
int n,res=0;
cin>>n;
for (int i=1;i<=n;i++)