北航忘了第几次上机的题解(3.27)

都是模拟,自行食用
A

/* Author: 张皓南 Result: AC Submission_id: 2384206 Created at: Fri Mar 27 2020 20:47:33 GMT+0800 (CST) Problem_id: 3143 Time: 16 Memory: 1692 */

#include<stdio.h>
#include<math.h>
int n,i,j,m;
double money;
double bj;
char c;
double ch,maxx,x;
int main(){
   
	scanf("%lf%d",&money,&n);bj=money;
	for(i=1;i<=n;i++){
   
		c=getchar();
		while(c=='\n'||c=='\r') c=getchar();
		scanf("%lf",&ch);
		if(c=='+'){
   
			money+=ch;
			bj+=(int)ch;
		}
		else if(c=='-'){
   
			money-=ch;
			bj-=(int)ch;
		}
		scanf("%d",&m);
		maxx=0;
		for(j=1;j<=m;j++){
   
			scanf("%lf",&x);
			if(x>maxx) maxx=x;
		}
		money=money*(1+maxx/100);
	}
	printf("%.2lf",money-bj);
	return 0;
}

B

/* Author: 张皓南 Result: AC Submission_id: 2379208 Created at: Fri Mar 27 2020 19:22:15 GMT+0800 (CST) Problem_id: 3125 Time: 2 Memory: 1668 */

#include <stdio.h>
char s[5005];
double a,b;
char d;
int main(){
   
	while(scanf("%lf %c %lf",&a,&d,&b)!=EOF){
   
		if(b==0){
   
			puts("Wrong Input");
		}
		else if(d=='+'){
   
			printf("%.2lf\n",(double)(a)+(double)(b));
		}
		else if(d=='-')printf("%.2lf\n",(double)(a)-(double)(b));
		else if(d=='*')printf("%.2lf\n",(double)(a)*(double)(b));
		else if(d=='/')printf("%.2lf\n",(double)(a)/(double)(b));
	}
	return 0;
}

C

/* Author: 张皓南 Result: AC Submission_id: 2383546 Created at: Fri Mar 27 2020 20:37:04 GMT+0800 (CST) Problem_id: 3144 Time: 5 Memory: 1644 */

#include <stdio.h>
int n,i,j,x;
int main(){
   
	while(scanf("%d",&x)!=EOF){
   
	   	n=2*x+1;
		for(i=1;i<=n;i++){
   
	   	   if(i==(n+1)/2){
   
	   	      for(j=1;j<=n;j++) printf("*");	
	   	      printf("\n"); 
		   }
		   else{
   
		   	  for(j=1;j<=n;j++){
   
		   	    if(i==j||j==(n-i+1)) printf("*");
				else printf(" ");	
			  }
			  printf("\n");
		   } 	
		}
		
		printf("\n");
	}
    return 0;
}

D

/* Author: 张皓南 Result: AC Submission_id: 2385412 Created at: Fri Mar 27 2020 21:31:59 GMT+0800 (CST) Problem_id: 3138 Time: 10 Memory: 1700 */

#include <stdio.h>
long long n,i,j;
long long l,r;
long long a[105],sum[105];
long long ans;
int main(){
   
	while(scanf("%lld",&n)!=EOF){
   
		ans=0;
		l=0,r=0;
		sum[0]=0;
		for(i=1;i<=n;i++) scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i];
		for(i=1;i<=n;i++){
   //左端点 
			for(j=i;j<=n;j++){
   //右端点 
				if(sum[j]-sum[i-1]>ans){
   
					r=j;
					l=i;
					ans=sum[j]-sum[i-1];
				}
				else if(sum[j]-sum[i-1]==ans){
   
					if(j-i>r-l){
   
						r=j;
						l=i;
					}
				}
			}
		}
		if(l==0&&r==0) puts("I'm hungry!");
		else  printf("%lld %lld %lld\n",ans,l,r);
	}
	return 0;
}

E

/* Author: 张皓南 Result: AC Submission_id: 2381969 Created at: Fri Mar 27 2020 20:10:16 GMT+0800 (CST) Problem_id: 3142 Time: 10 Memory: 2412 */

#include <stdio.h>
#include <math.h> 

#define PI 3.14159265
int a,b;
int main(){
   
	scanf("%d%d",&a,&b);
	if(b==0&&a>0) printf("E");
	else if(b==0&&a<0) printf("W");
	else if(a==0&&b>0) printf("N");
	else if(a==0&&b<0) printf("S"); 
	else if(a==0&&b==0)printf("Bingo"); 
    else {
   
	double x=(double)(b)/a;
    double angle=atan(x)*180/ PI;//计算以角度表示的x的反正切
    if(a>0&&b>0)printf("NE%.2f", 90.00-angle); 
    else if(a<0&&b>0)printf("NW%.2f",90.00+angle);
    else if(a<0&&b<0) printf("SW%.2lf",90.00-angle);
    else if(a>0&&b<0) printf("SE%.2f",90.00+angle);
	}

    return 0;
}

F

/* Author: 张皓南 Result: AC Submission_id: 2384861 Created at: Fri Mar 27 2020 20:56:37 GMT+0800 (CST) Problem_id: 3134 Time: 1 Memory: 1544 */

#include<stdio.h>
int n;
int main(){
   
	while(scanf("%d",&n)!=EOF){
   
		if(n<=2){
   
			printf("3.183263598\n");
		}
                else if(n<=4){
   
			printf("3.140597029\n");
		}else if(n<=6){
   
			printf("3.141621029\n");
		}else if(n<=8){
   
			printf("3.141591772\n");
		}else if(n<=10){
   
			printf("3.141592682\n");
		}else if(n<=12){
   
			printf("3.141592653\n");
		}else if(n<=14){
   
			printf("3.141592654\n");
		}else if(n<=16){
   
			printf("3.141592654\n");
		}else if(n<=18){
   
			printf("3.141592654\n");
		}else{
   
			printf("3.141592654\n");
		}
	}
	return 0;
}

G

/* Author: 张皓南 Result: AC Submission_id: 2386876 Created at: Fri Mar 27 2020 22:08:50 GMT+0800 (CST) Problem_id: 3145 Time: 56 Memory: 1696 */

#include<stdio.h>
#include<math.h>
#define modd 1e-6
double m,b,k,x0,t0,zhn,a,jj,z;
long long i;
int main(){
   
	scanf("%lf%lf%lf%lf%lf",&m,&b,&k,&x0,&t0);
	zhn=0.0;
	a=0.0;
	jj=x0;
	z=0.0;
	for(i=1;i*modd<t0;i++){
   
		zhn=jj+modd*z;
		a=z-modd*(b*z+k*jj)/m;
		jj=zhn;
		z=a;
	}
	printf("%.8lf",zhn);
	return 0;
}

H

/* Author: 张皓南 Result: AC Submission_id: 2385084 Created at: Fri Mar 27 2020 20:59:01 GMT+0800 (CST) Problem_id: 3111 Time: 55 Memory: 1688 */

#include <stdio.h>
long long n,i,x;
int main(){
   
   scanf("%lld",&n);
   long long ans=1;
   for(i=1;i<=2*n-1;i++) scanf("%lld",&x),ans=ans^x;
   ans=ans^1;
   printf("%lld",ans);
   return 0;
}

I

/* Author: 张皓南 Result: AC Submission_id: 2378978 Created at: Fri Mar 27 2020 19:13:44 GMT+0800 (CST) Problem_id: 3135 Time: 10 Memory: 1696 */

#include <stdio.h>
int n,i,x,ans;
int a[10005];
int main(){
   
	scanf("%d",&n);
	for(i=1;i<=n+1;i++){
   
		scanf("%d",&x);
		if(a[x]==0) a[x]=1;
		else if(a[x]==1) ans=x; 
	}
	printf("%d",ans);
	return 0;
}

J

/* Author: 张皓南 Result: AC Submission_id: 2389670 Created at: Sat Mar 28 2020 00:32:10 GMT+0800 (CST) Problem_id: 3140 Time: 3 Memory: 1684 */

#include <stdio.h>
int a[30];
int d,i,q,j,k;
int ge,shi,bai;
int year2,mo,da,qian;
int ii;
int b[30];

int main(){
   
// printf("%d",192%100);
    a[1]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[10]=a[11]=1;
    a[9]=12;
    a[12]=3;
    b[1]=b[3]=b[5]=b[7]=b[12]=b[8]=b[10]=31;
    b[4]=b[6]=b[9]=b[11]=30;
    scanf("%d",&q);
    while(q--){
   	
       int ans=0;
        scanf("%d%d%d",&year2,&mo,&da);
    	for(i=1;i<year2;i++){
   
          if(i%4==0&&i%100!=0||i%400==0) d=366,a[2]=3;
          else d=365,a[2]=2;       
          j=i%1000;
          k=i%100;
          ge=i%10;
          shi=(k-ge)/10;
          bai=(j-k)/100;
		  if(k==29||k==92||j==209||j==219||j==239||j==249||j==259||j==269||j==279||j==289||(j<=299&&j>=290)||j==902||j==912||(j>=920&&j<=929)||j==932||j==942||j==952||j==962||j==972||j==982) ans=ans+d;
		  else{
   		  	
		  	if(bai==9||shi==9||ge==9) ans+=179;
			else if(bai==2||shi==2||ge==2) ans+=62;
			else ans+=26;
			if(a[2]==3) ans++;
		  }
	    }
	    
	    
	
	  if(year2%4==0&&year2%100!=0||year2%400==0) a[2]=3,b[2]=29;
      else a[2]=2,b[2]=28;
      
      i=year2;
	  j=i%1000;
	  qian=i/1000; 
      k=i%100;
      ge=i%10;
      shi=(k-ge)/10;
      bai=(j-k)/100;
	  if(k==29||k==92||j==129||j==192||j==209||j==219||j==229||j==239||j==249||j==259||j==269||j==279||j==289||(j<=299&&j>=290)||j==902||j==912||(j>=920&&j<=929)||j==932||j==942||j==952||j==962||j==972||j==982) {
   
	      
	      for(ii=1;ii<mo;ii++) ans+=b[ii];   ans+=da;
	  }
	  else if(bai==9||ge==9||shi==9){
   

	  	for(ii=1;ii<mo;ii++) {
   
		    if(ii!=2) ans+=a[9];
		    else if(ii==2) {
   
		    	if(year2%4==0&&year2%100!=0||year2%400==0) ans+=29;
		    	else ans+=28;
			}
		  }
		  
		  if(mo==2) ans+=da;
		  else if(mo==12) ans+=da;
		  
		  else {
   
		  	for(ii=1;ii<=da;ii++){
   
		  		if(ii==2||ii==12||(ii>=20&&ii<=29)) ans++;
			  }
		  }
	  } 
	  
	  else if(bai==2||ge==2||shi==2||qian==2){
   
	    
	  	for(ii=1;ii<mo;ii++){
   
	  	     if(ii!=9&&ii!=2)	ans+=a[12];
	  	     else if(ii==2){
   
	  	     	if(b[2]==29) ans+=a[12];
	  	     	else ans+=a[12]-1;
			 } 
	  	     else if(ii==9)ans+=30;
		}
		if(mo==9) ans+=da;
		else{
   
			for(ii=1;ii<=da;ii++){
   
		  		if(ii==9||ii==19||ii==29) ans++;
			  }	
		}
	  }  
	  else {
   
	  	for(ii=1;ii<mo;ii++) ans+=a[ii];
	  	if(mo==2){
   
	  		if(da>=9&&da<19) ans++;
			else if(da>=19&&da<29) ans=ans+2;
			else if(da==29) ans=ans+3; 
		}
		else if(mo==9){
   
			if(da>=29) ans+=12;
			else if(da>=2&&da<12) ans++;
			else if(da>=12&&da<20) ans=ans+2;
			else if(da>=20&&da<29) ans=ans+3+(da-20);
		}
		else if(mo==12){
   
			if(da>=9&&da<19) ans++;
			else if(da>=19&&da<29) ans=ans+2;
			else if(da>=29) ans=ans+3;
		}
		else{
   
			if(da>=29) ans++;
		}
	  }
	   printf("%d\n",ans);
	}
	return 0;
}

K

/* Author: 张皓南 Result: AC Submission_id: 2391328 Created at: Sat Mar 28 2020 10:27:15 GMT+0800 (CST) Problem_id: 3151 Time: 16 Memory: 1712 */

#include <stdio.h>
int bi[10];
int ben[10];
int i;
int flag;
int gcd(int x,int y){
   
	if(!y) return x;
	else return gcd(y,x%y);
}
int pd(int x,int y){
   
	if(x==0&&(y==1||y==-1)){
   
		return 0;
	}
	else if(y==0&&(x==1||x==-1)){
   
		return 0;
	}
	else if(x==0&&y==0){
   
		return 1;
	}
	else if(x==0||y==0){
   
		return 1;
	}
	
	else {
   
		
	if(x<0) x=x*(-1);
	if(y<0) y=y*(-1);
	if(gcd(x,y)!=1) return 1;
	else  return 0;		
	}
}
inline int read(){
   
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
   if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){
   x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
   
   while(scanf("%d%d%d%d",&bi[1],&bi[2],&bi[3],&bi[4])==4){
   
   	    flag=0;
	   for(i=1;i<=4;i++) ben[i]=read();
	   
   	   if(pd(bi[1],ben[1])&&pd(bi[2],ben[2])&&pd(bi[3],ben[3])&&pd(bi[4],ben[4])){
   
   	   	printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[4]);
   	   	   flag=1;
	   }
	   
	    else if(pd(bi[1],ben[1])&&pd(bi[2],ben[2])&&pd(bi[3],ben[4])&&pd(bi[4],ben[3])){
   
   	   	   flag=1;
   	   	printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);
	   }
	   
	   
	    else if(pd(bi[1],ben[1])&&pd(bi[2],ben[3])&&pd(bi[3],ben[2])&&pd(bi[4],ben[4])){
   
   	   	printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[4]);   
		flag=1;
	   }
	   
	    else if(pd(bi[1],ben[1])&&pd(bi[2],ben[3])&&pd(bi[3],ben[4])&&pd(bi[4],ben[2])){
   
   	   	  
		printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);   
	    flag=1;
	   }
	     else if(pd(bi[1],ben[2])&&pd(bi[2],ben[1])&&pd(bi[3],ben[4])&&pd(bi[4],ben[3])){
   
	    printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);
   	   	   flag=1;
	   }
	   else if(pd(bi[1],ben[1])&&pd(bi[2],ben[4])&&pd(bi[3],ben[2])&&pd(bi[4],ben[3])){
   
   	   	   flag=1;
   	   	printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);   
	   }
	    else if(pd(bi[1],ben[1])&&pd(bi[2],ben[4])&&pd(bi[3],ben[3])&&pd(bi[4],ben[2])){
   
   	   	   flag=1;
   	   	printf("%dvs%d\n",bi[1],ben[1]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);   
	   }
	   else if(pd(bi[1],ben[2])&&pd(bi[2],ben[1])&&pd(bi[3],ben[3])&&pd(bi[4],ben[4])){
   
   	   	printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[4]);
				flag=1;
	   }
	 
	   else if(pd(bi[1],ben[2])&&pd(bi[2],ben[3])&&pd(bi[3],ben[1])&&pd(bi[4],ben[4])){
   
   	   	  
				   	   	printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[4]); flag=1;
	   }
	  else  if(pd(bi[1],ben[2])&&pd(bi[2],ben[3])&&pd(bi[3],ben[4])&&pd(bi[4],ben[1])){
   
   	   	  
		printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);  
			  flag=1;
	   }
	   else if(pd(bi[1],ben[2])&&pd(bi[2],ben[4])&&pd(bi[3],ben[1])&&pd(bi[4],ben[3])){
   
	   	printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);  	
   	   	   flag=1;
	   }
	  else  if(pd(bi[1],ben[2])&&pd(bi[2],ben[4])&&pd(bi[3],ben[3])&&pd(bi[4],ben[1])){
   
	    		   	printf("%dvs%d\n",bi[1],ben[2]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);  	
	    	
   	   	   flag=1;
	   }
	   else if(pd(bi[1],ben[3])&&pd(bi[2],ben[1])&&pd(bi[3],ben[2])&&pd(bi[4],ben[4])){
   
   	   	printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[4]);  	
				 flag=1;
	   }
	    else if(pd(bi[1],ben[3])&&pd(bi[2],ben[1])&&pd(bi[3],ben[4])&&pd(bi[4],ben[2])){
   
   	   	   	printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);  flag=1;
	   }
	    else if(pd(bi[1],ben[3])&&pd(bi[2],ben[2])&&pd(bi[3],ben[1])&&pd(bi[4],ben[4])){
   
   	   	  
		printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[4]);   flag=1;
	   }
	    else if(pd(bi[1],ben[3])&&pd(bi[2],ben[2])&&pd(bi[3],ben[4])&&pd(bi[4],ben[1])){
   
   	   	  
		printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[4]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);  flag=1;
	   }
	   else if(pd(bi[1],ben[3])&&pd(bi[2],ben[4])&&pd(bi[3],ben[1])&&pd(bi[4],ben[2])){
   
   	   	
		printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);    flag=1;
	   }
	   else if(pd(bi[1],ben[3])&&pd(bi[2],ben[4])&&pd(bi[3],ben[2])&&pd(bi[4],ben[1])){
   
   	   	 
		printf("%dvs%d\n",bi[1],ben[3]);
   	   	printf("%dvs%d\n",bi[2],ben[4]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);     
			  flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[1])&&pd(bi[3],ben[2])&&pd(bi[4],ben[3])){
   
	    			printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);   
   	   	   flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[1])&&pd(bi[3],ben[3])&&pd(bi[4],ben[2])){
   
   	   	
		printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[1]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);    flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[2])&&pd(bi[3],ben[1])&&pd(bi[4],ben[3])){
   
   	   	printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[3]);     
				 flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[2])&&pd(bi[3],ben[3])&&pd(bi[4],ben[1])){
   
   	   	 
		printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[2]);
   	   	printf("%dvs%d\n",bi[3],ben[3]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);     
			    flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[3])&&pd(bi[3],ben[1])&&pd(bi[4],ben[2])){
   
   	   	 
		printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[1]);
   	   	printf("%dvs%d\n",bi[4],ben[2]);       flag=1;
	   }
	   else if(pd(bi[1],ben[4])&&pd(bi[2],ben[3])&&pd(bi[3],ben[2])&&pd(bi[4],ben[1])){
   
   	   	printf("%dvs%d\n",bi[1],ben[4]);
   	   	printf("%dvs%d\n",bi[2],ben[3]);
   	   	printf("%dvs%d\n",bi[3],ben[2]);
   	   	printf("%dvs%d\n",bi[4],ben[1]);     
				 flag=1;
	   }
	   if(!flag){
   
	   	  puts("As we can't.");
	   }
   }
	return 0;
}

L

/* Author: 张皓南 Result: AC Submission_id: 2379931 Created at: Fri Mar 27 2020 19:36:34 GMT+0800 (CST) Problem_id: 3153 Time: 62 Memory: 1952 */

#include <stdio.h>
int n,i;
int mon,flag,mon2,mon5;
int a[100005];
int main(){
   
	while(scanf("%d",&n)!=EOF){
   
		mon=0;
		mon2=0;
		mon5=0;
		flag=0;
		for(i=1;i<=n;i++) scanf("%d",&a[i]);
		for(i=1;i<=n;i++){
   
			if(a[i]==1) mon++;
			
			else if(a[i]==2){
   //2酷爱 
				if(mon<1){
   
					flag=1;
					break;
				}
				else{
   
					mon--;
					mon2++;
				} 
			}
			
			else if(a[i]==5){
   
				if(mon+mon2*2<4){
   
					flag=1;
					break;
				}
				else{
   
				    mon5++;
					if(mon2*2>=4){
   
						mon2=mon2-2;
					}
					else if(mon2==1){
   
						mon2--;
						mon=mon-2;
					}
					else if(!mon2){
   
						mon=mon-4;
					}
				}
			} 
		}
		if(!flag) puts("Survived.");
		else if(flag) puts("Bankrupted.");
	}
	return 0;
}

注意!此信息未认证,请谨慎判断信息的真实性!

全部评论
空

相关内容推荐

头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
点赞 评论 收藏
转发
头像
点赞 评论 收藏
转发
点赞 收藏 评论
分享

全站热榜

正在热议