上机(8)

最近有点累啊QWQ

A

/* Author: 张皓南 Result: AC Submission_id: 2613676 Created at: Fri May 15 2020 19:26:01 GMT+0800 (China Standard Time) Problem_id: 3385 Time: 4 Memory: 1580 */

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main()
{
   
    char a;
    while(1){
   
        a=getchar();
        if(a=='\r'){
   
            printf("WINDOWS");
           return 0;
        }
        if(a=='\n'){
   
            printf("LINUX");
            return 0;
        }
    }
    return 0;
}

B

/* Author: 张皓南 Result: AC Submission_id: 2613565 Created at: Fri May 15 2020 19:24:07 GMT+0800 (China Standard Time) Problem_id: 3387 Time: 6 Memory: 1692 */

#include <stdio.h>
#include <math.h>
#define int long long 
int x,xx,xxx,xxxx;
int y,yy,yyy,yyyy;
int d1,d2;
int num[15];
int cmp ( const void *a , const void *b ){
   
  return *(int *)b - *(int *)a; 
}
main(){
   
	scanf("%lld%lld",&x,&y);
	scanf("%lld%lld",&xx,&yy);
	scanf("%lld%lld",&xxx,&yyy);
	scanf("%lld%lld",&xxxx,&yyyy);
	if(xxx>=xx||xxxx<=x||yyyy<=y||yyy>=yy) printf("0");
	else{
   
		num[0]=x;
		num[1]=xx;
		num[2]=xxx;
		num[3]=xxxx;
		qsort(num,4,sizeof(num[0]),cmp);
		d1=num[1]-num[2];
		num[0]=y;
		num[1]=yy;
		num[2]=yyy;
		num[3]=yyyy;
		qsort(num,4,sizeof(num[0]),cmp);
		d2=num[1]-num[2];
		printf("%lld",d1*d2);
	}
	return 0;
}

C

/* Author: 张皓南 Result: AC Submission_id: 2616602 Created at: Fri May 15 2020 20:15:05 GMT+0800 (China Standard Time) Problem_id: 3388 Time: 96 Memory: 4396 */

#define mian main
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
struct NODE{
   
    char nn[20];
    int uid;
    int rating;
}zhn[111111];
int n,i;
int uu,rank,lgr;
int main(){
   
    uu=2333333;
    rank=-100000;
    scanf("%d",&n);
    for (i=1;i<=n;i++){
   
        scanf("%s%d%d", &zhn[i].nn, &zhn[i].uid, &zhn[i].rating);
        if (zhn[i].rating==rank){
   
            if (zhn[i].uid<uu){
   
                uu=zhn[i].uid;
                lgr=i;
            }
        }
        else if (zhn[i].rating>rank){
   
            rank=zhn[i].rating;
            uu=zhn[i].uid;
            lgr=i;
        }
    }
    printf("%s %d %d", zhn[lgr].nn,zhn[lgr].uid,zhn[lgr].rating);
    return 0;
}

D

/* Author: 张皓南 Result: AC Submission_id: 2622032 Created at: Sat May 16 2020 00:01:59 GMT+0800 (China Standard Time) Problem_id: 3390 Time: 120 Memory: 1628 */

#include <stdio.h>
#include <string.h>
char s1[1005];
char s2[1005];
char s3[40005];
char s4[30105],tmp[2005];
char zhnn(char *s){
   
	int l = strlen(s);
	if(s[l-1] == '\r'){
   
		s[l-1] = '\0';
	}
	return *s;
}
int main(){
   
	gets(s1);
	gets(s2);
	zhnn(s2);
	zhnn(s1);
	int len1=strlen(s1);
	int len2=strlen(s2);
	strcpy(tmp, s1);
	strcat(tmp, s2);
	char *p, *q;
	while(gets(s3)!=NULL){
   
		zhnn(s3);
		p=strstr(s3,s1);
		if(p!=NULL){
   
			if(strcmp(p,tmp)==0){
   
				continue;
			}
			else{
   
				strcat(s4, p+len1);
				continue;
			}
		}
		else continue;
	}
	int len=strlen(s4);
	printf("%d\n", len);
	printf("%s#END\n", s4);
	return 0;
}

E

/* Author: 张皓南 Result: AC Submission_id: 2622215 Created at: Sat May 16 2020 00:31:00 GMT+0800 (China Standard Time) Problem_id: 3392 Time: 176 Memory: 5812 */

#include<stdio.h>
#include<math.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
typedef struct{
   
	char nam[60];
	int mo;
	int day;
	int cnt;
}v;
v zhn[100500];
int cmp(const void *a ,const void *b) {
    
	if((*(v *)a).mo-(*(v *)b).mo!=0)
	return (*(v *)a).mo-(*(v *)b).mo;
	else{
   
		if((*(v *)a).day-(*(v *)b).day!=0){
   
			return (*(v *)a).day-(*(v *)b).day;
		}
		else return strcmp((*(v *)a).nam,(*(v *)b).nam);
	}
} 
char laji[10];
int i,ye,n;
int main(){
   
	scanf("%d",&n);
	if(n==0)return 0;
	gets(laji);
	for(i=0;i<n;i++){
   
		scanf("%s %d:%d:%d",zhn[i].nam,&ye,&zhn[i].mo,&zhn[i].day);
		gets(laji);
	}
	qsort(zhn,n,sizeof(zhn[0]),cmp);
	printf("%d:%d %s",zhn[0].mo,zhn[0].day,zhn[0].nam);
	for(i=1;i<n;i++){
   
		if(zhn[i].mo==zhn[i-1].mo&&zhn[i].day==zhn[i-1].day){
   
			printf(" %s",zhn[i].nam);
		}
		else{
   
			printf("\n");
			printf("%d:%d %s",zhn[i].mo,zhn[i].day,zhn[i].nam);
		}
	}
	return 0;
}

F

/* Author: 张皓南 Result: AC Submission_id: 2621295 Created at: Fri May 15 2020 22:55:25 GMT+0800 (China Standard Time) Problem_id: 3391 Time: 4 Memory: 1712 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h> 
double a,b,c;
int n,m,i,t;
int main(){
   
    while (scanf("%lf%d",&a,&n)!=EOF){
   
    	c=0.5;
    	for (i=1;i<=n;i++) a=a*10;
		m=floor(a);
		a=a-m;
		t=m;
		if(fabs(a-c)<1e-16)
		   if ((m%10)%2!=0) t++;	
		if (a>c) t++;
		b=t;
	    for (i=1;i<=n;i++) b=b/10;
	   	printf("%.*lf\n",n,b);
}
          
	return 0;
}

H

/* Author: 张皓南 Result: AC Submission_id: 2615782 Created at: Fri May 15 2020 20:01:25 GMT+0800 (China Standard Time) Problem_id: 3389 Time: 27 Memory: 2168 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define int long long
const int mod=1000000007;
typedef struct jz{
   
    long long s[55][55];
}juzhen;
juzhen lgr(juzhen a, juzhen b, int size){
   
    int i, j, id;
    juzhen c;
    memset(c.s, 0, sizeof(c.s));
    for (i = 0; i < size; i++){
   
    	for (j = 0; j < size; j++){
   
    		for (id = 0; id < size; ++id){
   
    			c.s[i][j] += a.s[i][id] * b.s[id][j];
    			if(c.s[i][j]>mod){
   
    				c.s[i][j]%=mod;
				}
			}
		}    
	}
    return c;
}
juzhen Pow(juzhen src, int size, int t){
   
    juzhen d;
    int i;
    if (t == 0)
    {
   
        memset(d.s, 0, sizeof(d.s));
        for (i = 0; i < size; i++){
   
        	d.s[i][i] = 1;
		}
        return d;
    }
    else{
   
        juzhen des = Pow(src, size, t / 2);
        if (t&1)return lgr(lgr(des, des, size), src, size);
		else	return lgr(des, des, size);	
    }
}
main(){
   
    int n, k, i, j;
    scanf("%lld%lld", &n, &k);
    juzhen a;
    for (i = 0; i < n; ++i){
   
        for (j = 0; j < n; ++j){
   
            scanf("%lld", &a.s[i][j]);
		}
	}
    juzhen zhn=Pow(a, n, k);
    for(i=0;i<n;++i){
   
        for(j=0;j<n;++j){
   
        	if(zhn.s[i][j]>mod)zhn.s[i][j]%=mod;
            if (j==n-1)printf("%lld\n", zhn.s[i][j]);
            else printf("%lld ", zhn.s[i][j]);
        }
    }
    return 0;
}

I

/* Author: 张皓南 Result: AC Submission_id: 2619755 Created at: Fri May 15 2020 21:35:19 GMT+0800 (China Standard Time) Problem_id: 3383 Time: 191 Memory: 1676 */

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int n,zhn[50],t,i,j;
int wei[50];
int flag;
void dfs(int loc,int mon){
   
	if(mon<0) return ;
	else if(loc==n+1&&mon==0){
   
		for(i=1;i<=n;i++) printf("%d ",wei[i]);
		flag=1;
		printf("\n");
		return ;
	}
	else if(loc>n) return ;
	else{
   
		for(int j=1;j<=t/zhn[loc];j++){
   
			wei[loc]=j;
			dfs(loc+1,mon-j*zhn[loc]);
			wei[loc]=0;		
		}
	}
	return ;
} 
int main(){
   
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&zhn[i]);
	scanf("%d",&t);
	dfs(1,t);
	if(!flag) printf("Sorry, you failed.");
	return 0;
}

J

/* Author: 张皓南 Result: AC Submission_id: 2621935 Created at: Fri May 15 2020 23:46:38 GMT+0800 (China Standard Time) Problem_id: 3334 Time: 6 Memory: 1964 */

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h> 
int m,n;
char a[1000][1000];
char bz[4][10]={
   " +---+ "," / \\ ","+ +"," \\ / "};
int main(){
   
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
   
		for(int j=1;j<=n;j++){
   
			int c=4*j-2+(i%2==0?2:0);
			int b=6*(i-1);
			strcpy(a[c-2]+b,bz[0]);
	        strcpy(a[c-1]+b,bz[1]);
			strcpy(a[c]+b,bz[2]);
			strcpy(a[c+1]+b,bz[3]);
			strcpy(a[c+2]+b,bz[0]);
		}
	}
	for(int i=0;i<(m>1?4*n+2:4*n)+1;i++){
   
		for(int j=0;j<=6*m+2;j++){
   
			if(a[i][j]=='\0'){
   
				a[i][j]=' ';
			}
		}
	}
	for(int i=0;i<(m>1?4*n+2:4*n)+1;i++)printf("%s\n",a[i]);
	return 0;
}

K

/* Author: 张皓南 Result: AC Submission_id: 2616791 Created at: Fri May 15 2020 20:18:07 GMT+0800 (China Standard Time) Problem_id: 3011 Time: 22 Memory: 1720 */

#include <stdio.h>
#include <string.h>
int x;
char zhn[1001][25];
int main(){
   
    scanf("%d",&x);
    int i=0;
    while(gets(zhn[i])!=NULL){
   
        i++;
        if(i>1000) i=0;
    }
    i-=x;
    if(i<0)i+=1001;
    printf("%s",zhn[i]);
    return 0;
}

L

/* Author: 张皓南 Result: AC Submission_id: 2623486 Created at: Sat May 16 2020 11:26:19 GMT+0800 (China Standard Time) Problem_id: 3384 Time: 73 Memory: 3284 */

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h> 

struct NODE{
   
	char name[20];
	struct NODE *nex;
};
struct NODE* head[100005];
struct NODE* tail[100005];
struct NODE * tmp;
char zhn[25];
int n,m,op,ren,lgr;
int main(){
   
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) head[i]=NULL,tail[i]=NULL;
	for(int i=1;i<=m;i++){
   
		scanf("%d",&op);
		if(op==1){
   
			scanf("%d",&ren);
			tmp=head[ren];
			head[ren]=head[ren]->nex;
			free(tmp);
		}
		else if(op==2){
   
			scanf("%d %s",&ren,zhn);
			struct NODE* q=(struct NODE*)malloc(sizeof(struct NODE));
			q->nex=NULL;
			strcpy(q->name,zhn);
			if(head[ren]==NULL){
   
				head[ren]=q;				
				tail[ren]=q;
			}
			else{
   
				tail[ren]->nex=q;
				tail[ren]=q;
			}			
		}
		else if(op==3){
   
			scanf("%d %d",&ren,&lgr);
			if(head[ren]!=NULL){
   
				if(head[lgr]==NULL)head[lgr]=head[ren];				
				else tail[lgr]->nex=head[ren];
				tail[lgr]=tail[ren];
				head[ren]=NULL;	
				tail[ren]=NULL;
			}
		}
		else if(op==4){
   
			scanf("%d",&ren);
			if(head[ren]==NULL)printf("Done\n");
			else{
   
				tmp=head[ren];
				while(tmp!=NULL){
   
					printf("%s ",tmp->name);
					tmp=tmp->nex;
				}
				printf("\n");
			}
		}
	} 
	return 0;
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务