//// Created by 22385 on 2022/1/17.////B1008 数组循环右移//算法思想:转置#include<stdio.h>voidreverse(int a[],int low,int high);intmain(){int n,p;scanf("%d %d",&n,&p);
p=p%n;//注意移动的序列的合法性int a[n]={0};for(int i=0;i<n;i++){scanf("%d",&a[i]);}reverse(a,0,n-1);reverse(a,0,p-1);reverse(a,p,n-1);for(int i=0;i<n;i++){if(i!=0){printf(" ");}printf("%d",a[i]);}return0;}voidreverse(int a[],int low,int high){int mid=(high-low+1)/2;int temp;for(int i=0;i<mid;i++){
temp=a[low+i];
a[low+i]=a[high-i];
a[high-i]=temp;}}
B1010
//// Created by 22385 on 2022/1/17.//#include<stdio.h>//只有“零多项式”才输出“0 0 ”intmain(){int a,n;char flag =' ';bool tag=false;while(flag!='\n'){scanf("%d %d",&a,&n);
flag=getchar();if(n==0&&!tag && flag =='\n'){printf("0 0");}elseif(n!=0){if(tag){printf(" ");}
tag=true;printf("%d %d",a*n,n-1);//iclon会自动帮你删去最后一个空格....}}return0;}
B1011
//// Created by 22385 on 2022/1/14.//#include<stdio.h>#include<valarray>intmain(){longlong a,b,c;int n;scanf("%d",&n);int result[n];for(int i=1;i<=n;i++){scanf("%lld %lld %lld",&a,&b,&c);//读入longlong型数据要用:%lld
result[i]=a+b>c?1:0;}for(int i=1;i<=n;i++){if(result[i]==1){printf("Case #%d: true\n",i);}else{printf("Case #%d: false\n",i);}}return0;}
B1012
//// Created by 22385 on 2022/1/17.//#include<stdio.h>intmain(){int n;scanf("%d",&n);int array[n]={0};int A[5]={0};int flag[5]={0};int count=0;for(int i=0;i<n;i++){scanf("%d",&array[i]);if(array[i]%5==0&& array[i]%2==0){if(flag[0]==0)
flag[0]=1;
A[0]+=array[i];}if(array[i]%5==1){if(flag[1]==0)
flag[1]=1;
A[1]+=array[i]*flag[1];
flag[1]*=-1;//交错序列和可能为0,但是不能输出N}if(array[i]%5==2){if(flag[2]==0)
flag[2]=1;
A[2]++;}if(array[i]%5==3){if(flag[3]==0)
flag[3]=1;
A[3]+=array[i];
count++;}if(array[i]%5==4){if(flag[4]==0)
flag[4]=1;if(array[i]>A[4]){
A[4]=array[i];}}}for(int i=0;i<5;i++){if(i!=0){printf(" ");}if(i==3){if(flag[i]==0){printf("N");}else{printf("%.1f",A[i]*1.0/count);}}else{if(flag[i]==0){printf("N");}else{printf("%d",A[i]);}}}return0;}
B1016
//// Created by 22385 on 2022/1/17.//// B1016 部分A+B#include<stdio.h>intmain(){int A,B,DA,DB;int PA=0,PB=0;scanf("%d %d %d %d",&A,&DA,&B,&DB);while(A!=0){if(A%10==DA){
PA=PA*10+DA;}
A/=10;}while(B!=0){if(B%10==DB){
PB=PB*10+DB;}
B/=10;}printf("%d",PA+PB);return0;}
//// Created by 22385 on 2022/1/17.////B1026 程序运行时间#include<stdio.h>#defineCLK_TCK100;intmain(){int C1,C2;scanf("%d %d",&C1,&C2);int t=(C2-C1)/CLK_TCK;int h=0,m=0,s=0;
h=t/3600;
m=(t%3600)/60;if((C2-C1)%100>=50){
s=t%60+1;}else{
s=t%60;}printf("%02d:%02d:%02d",h,m,s);return0;}
B1032
// Created by 十五 on 2022/1/14.#include<stdio.h>intmain(){int n;scanf("%d",&n);/*1:
int a[n]={0};
*/int a[1000000]={0};int score;int id;int winner=0;for(int i=0;i<n;i++){scanf("%d %d",&id,&score);
a[id]+=score;if(a[id]>=a[winner]){
winner=id;}}printf("%d %d",winner,a[winner]);return0;}/*
试例2未通过:
可能只有一个学校,且成绩为0,但是需要输出该学校的编号
*/
B1046
//// Created by 22385 on 2022/1/17.//#include<stdio.h>intmain(){int n;scanf("%d",&n);int AShout,AShow;int BShout,BShow;int drinkA=0,drinkB=0;for(int i=0;i<n;i++){scanf("%d %d %d %d",&AShout,&AShow,&BShout,&BShow);if(AShow == BShow){continue;}else{if(AShow==(AShout+BShout)){
drinkB++;}elseif(BShow==(AShout+BShout)){
drinkA++;}}}printf("%d %d",drinkA,drinkB);return0;}
A1002
//// Created by 22385 on 2022/1/18.//#include<stdio.h>constint max_n=1111;double p[max_n]={0};//将多项式按幂次存入数组intmain(){int k,n,count=0;double a;//第一个多项式scanf("%d",&k);for(int i=0;i<k;i++){scanf("%d %lf",&n,&a);
p[n]=a;}//第二个多项式scanf("%d",&k);for(int i=0;i<k;i++){scanf("%d %lf",&n,&a);
p[n]+=a;}//统计非零项个数for(int i=0;i<max_n;i++){if(p[i]!=0) count++;}printf("%d",count);//按格式输出多项式的和for(int i=max_n-1;i>=0;i--){if(p[i]!=0){printf(" %d %.1lf",i,p[i]);}}}
A1009
//// Created by 22385 on 2022/1/18.////多项式乘法#include<stdio.h>#definemax_n2002//乘法,数组要开到两倍大intmain(){int ka,kb,n;double a;double p[max_n]={0};//数组定义在外面发生了段错误?????double pa[max_n]={0};scanf("%d",&ka);for(int i=0;i<ka;i++){scanf("%d %lf",&n,&a);
pa[n]=a;}scanf("%d",&kb);for(int i=0;i<kb;i++){scanf("%d %lf",&n,&a);for(int j=0;j<max_n;j++){//循环条件输错了
p[n+j]+=pa[j]*a;}}int count=0;for(int i=0;i<max_n;i++){if(p[i]!=0) count++;}printf("%d",count);for(int i=max_n-1;i>=0;i--){if(p[i]!=0){printf(" %d %.1lf",i,p[i]);}}return0;}
A1042
//// Created by 22385 on 2022/1/18.////多项式乘法#include<stdio.h>#definemax_n2002//乘法,数组要开到两倍大intmain(){int ka,kb,n;double a;double p[max_n]={0};//数组定义在外面发生了段错误?????double pa[max_n]={0};scanf("%d",&ka);for(int i=0;i<ka;i++){scanf("%d %lf",&n,&a);
pa[n]=a;}scanf("%d",&kb);for(int i=0;i<kb;i++){scanf("%d %lf",&n,&a);for(int j=0;j<max_n;j++){//循环条件输错了
p[n+j]+=pa[j]*a;}}int count=0;for(int i=0;i<max_n;i++){if(p[i]!=0) count++;}printf("%d",count);for(int i=max_n-1;i>=0;i--){if(p[i]!=0){printf(" %d %.1lf",i,p[i]);}}return0;}
A1046
//// Created by 22385 on 2022/1/17.//#include<stdio.h>intmain(){int n;scanf("%d",&n);int num[n+1]={0};int d;for(int i=1;i<=n;i++){//运行超时:不存储点的距离,直接存储路线距离scanf("%d",&d);
num[i]=num[i-1]+d;//num[i]:点1到点i+1的顺序路径长度}int test;scanf("%d",&test);int st,end;int sd;for(int i=0;i<test;i++){scanf("%d %d",&st,&end);if(st>end){int temp=end;
end=st;
st=temp;}if((num[end-1]-num[st-1])*2>num[n]){
sd=num[n]-(num[end-1]-num[st-1]);}else{
sd=num[end-1]-num[st-1];}printf("%d\n",sd);}return0;}
A1065
//// Created by 22385 on 2022/1/17.//#include<stdio.h>intmain(){int n;scanf("%d",&n);longlong a,b,c;for(int i=0;i<n;i++){scanf("%lld %lld %lld",&a,&b,&c);longlong sum =a+b;if(a>0&& b>0&& sum<0){//为什么必须将a+b存在sum中而不能直接比较printf("Case #%d: true\n",i+1);}elseif(a<0&& b<0&& sum>=0){printf("Case #%d: false\n",i+1);}else{if(a+b>c){printf("Case #%d: true\n",i+1);}else{printf("Case #%d: false\n",i+1);}}}return0;}