A.关电脑

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 int T,h1,m1,s1,h2,m2,s2,t1,t2,ans; 5 int main(){ 6 while(cin>>T){ 7 for(int cas=1;cas<=T;++cas){ 8 cin>>h1>>m1>>s1>>h2>>m2>>s2; 9 t1=h1*3600+m1*60+s1,t2=h2*3600+m2*60+s2; 10 ans=t2-t1+(t1>=t2?24*3600:0); 11 cout<<"Case #"<<cas<<": "<<ans<<endl; 12 } 13 } 14 return 0; 15 }
B.保护环境:大的矩形面积减去三个直角三角形的面积即可。

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 double a,b; 5 int main(){ 6 while(cin>>a>>b){ 7 cout<<setiosflags(ios::fixed)<<setprecision(2)<<(a+b)*a-a*a/2-(a+b)*b/2-(a-b)*b/2<<endl; 8 } 9 return 0; 10 }
C.车厘子的守护士兵1.0

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const int maxn=1005; 5 int n,L,R,l[maxn],r,ans; 6 int main(){ 7 while(cin>>n>>L>>R){ 8 ans=0; 9 for(int i=1;i<=n;++i)cin>>l[i]; 10 for(int i=1;i<=n;++i){ 11 cin>>r; 12 if((L<=i&&i<=R)&&(l[i]<=L&&R<=r))ans++; 13 } 14 cout<<ans<<endl; 15 } 16 return 0; 17 }
D.内心里的一把火:向量叉积求三角形面积,将以P为起点与之相连的三个三角形面积之和与A、B、C三点构成的三角形面积进行比较即可--->相关博文:向量叉积的运用

1 #include<bits/stdc++.h> 2 using namespace std; 3 struct node{int x,y;}nod[5]; 4 int a,b,sum,tmp; 5 inline int cross(node p0,node p1,node p2){ 6 return abs((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y)); 7 } 8 int main(){ 9 while(cin>>nod[0].x>>nod[0].y>>nod[1].x>>nod[1].y>>nod[2].x>>nod[2].y){ 10 cin>>nod[3].x>>nod[3].y,sum=0; 11 for(int i=1;i<=3;++i)sum+=cross(nod[3],nod[i-1],nod[i%3]); 12 tmp=cross(nod[0],nod[1],nod[2]); 13 puts(sum!=tmp?"NO":"YES"); 14 } 15 return 0; 16 }
E.分配物资

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const int maxn=1e6+5; 5 int n,m,q,x,y,z,a[maxn],ans[maxn];bool flag[maxn]; 6 int main(){ 7 while(cin>>n>>m>>q){ 8 memset(ans,0,sizeof(ans)); 9 memset(flag,false,sizeof(flag)); 10 memset(a,0,sizeof(a)); 11 for(int i=1;i<=n;++i)cin>>a[i]; 12 for(int i=1;i<=m;++i){ 13 cin>>x>>y; 14 if(a[x]>=y)///物资充足 15 flag[i]=true,a[x]-=y; 16 else ans[i]=y-a[x],a[x]=0;///同时置0 17 } 18 while(q--){ 19 cin>>z; 20 if(flag[z])puts("Yes"); 21 else cout<<ans[z]<<endl; 22 } 23 } 24 return 0; 25 }
F.吃饭啦

1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn=1005; 4 int n,m,a[maxn],x,q,ans,pos; 5 int main(){ 6 while(cin>>n>>m){ 7 memset(a,0,sizeof(a)); 8 for(int i=0;i<m;++i)cin>>a[i]; 9 sort(a,a+m); 10 cin>>q; 11 for(int i=1;i<=q;++i){ 12 cin>>x; 13 pos=lower_bound(a,a+m,x)-a; 14 ///cout<<"os:"<<pos<<endl; 15 if(pos==m)cout<<x-a[pos-1]<<endl;///找不到,则为x-a[pos-1] 16 else if(a[pos]==x)puts("0");///如果在某点上,则为0 17 else if(!pos)cout<<a[0]-x<<endl;///如果比第1个点位置小,则为a[0]-x 18 else cout<<min(a[pos]-x,x-a[pos-1])<<endl;///否则就取到两边绝对值最小的即可 19 } 20 } 21 return 0; 22 }
H.约会

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 LL x,y,a,z; 5 int main(){ 6 while(cin>>x>>y>>a){ 7 if(x<0)x=-x; 8 if(y<0)y=-y; 9 z=max(x,y); 10 if((x+y)&1)puts("Not the fate");///如果是奇数,则肯定走不到这个位置 11 else if((!x&&!y&&a)||(a<z)||((a-z)&1))puts("You are lying");///特殊情况x==0&&y==0&&a>0,肯定在说谎或者走的步数a小于z,则肯定还没走到或者a>z,则剩下的步数应为偶数,否则肯定是在说谎 12 else puts("We are together"); 13 } 14 return 0; 15 }
I.这是一个沙雕题I

1 #include<bits/stdc++.h> 2 using namespace std; 3 char str[105];int k,fuck,cnt[26];string ans,tmp;bool flag; 4 int main(){ 5 while(cin>>k){ 6 cin>>str,memset(cnt,0,sizeof(cnt)),ans=tmp="",flag=false,fuck=strlen(str); 7 for(int i=0;str[i];++i)cnt[str[i]-'a']++; 8 for(int i=0;i<26;++i) 9 if(cnt[i]&&cnt[i]%k!=0)flag=true;///如果不能被k整除,那么肯定不能构成k个相同的字符串 10 if(flag){puts("-1");continue;} 11 for(int i=0;i<26;++i){ 12 if(cnt[i]){///单个字符串拥有该字母的个数为cnt[i]/k 13 for(int j=1;j<=cnt[i]/k;++j)tmp+=i+'a'; 14 } 15 } 16 while(k--)ans+=tmp;///重复k次表示重新排列 17 cout<<ans<<endl; 18 } 19 return 0; 20 }
J.这是一个沙雕题II:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 LL n,k,ans,tmp1,tmp2,cnt1,cnt2,i,a[20],b[20],c[20]={1}; 5 int main(){ 6 for(i=1;i<19;++i)c[i]=c[i-1]*10;///预处理10^i 7 while(cin>>n>>k){ 8 ans=tmp1=n,tmp2=n-k,cnt1=cnt2=0; 9 while(tmp1)a[cnt1++]=tmp1%10,tmp1/=10,b[cnt2++]=tmp2%10,tmp2/=10; 10 for(i=cnt1-1;i>=0&&a[i]==b[i];--i);///遇到第一位不相等就退出,剩下的每一位填9 11 if(i>0&&((n+1LL)%c[i]))ans=n-n%c[i]-1;///前提是至少要在十位以上的某个位出现的数字不同即i>0,从那一位起剩下的位都填9,但还需要有一种特判情况,就是如果该数剩下的位已都是9,那么这时就不能再改变,因为要取最大,那么含尾数9最大的数就是n-n%a[i]-1。 12 cout<<ans<<endl;///否则输出原数字 13 } 14 return 0; 15 }
K.这是一个沙雕题III

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 int T;LL k,x,y,z; 5 int main(){ 6 while(cin>>T){ 7 while(T--){ 8 cin>>k>>x>>y;///最多能用z张抵扣券 9 if((z=k/x)*x<=k&&k<=z*y)puts("Y"); 10 else puts("N"); 11 } 12 } 13 return 0; 14 }