6 条题解

  • 1
    @ 2023-10-8 16:12:31
    #include<stdio.h>
    #include<math.h>
     
    int main()
    {
    	int n,count=0;
    	int a[1001][4]={0},sum[1001]={0};
    	
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)
    	{
    		scanf("%d %d %d",&a[i][1],&a[i][2],&a[i][3]);
    		sum[i]=a[i][1]+a[i][2]+a[i][3];
    	}
    	
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=i+1;j<=n;j++)
    		{
    			if(abs(a[i][1]-a[j][1])<=5 &&
    			   abs(a[i][2]-a[j][2])<=5 &&
    			   abs(a[i][3]-a[j][3])<=5 &&
    			   abs(sum[i]-sum[j])<=10)
    			   count++;
    		}
    	}
    	printf("%d",count);
    	
    	return 0;
    }
    
  • 1
    @ 2023-8-26 20:46:33

           \ \ \ \ \ \ \ 蚌埠住了,凭什么我的Python过不去。

    n = int(input())
    students = []
    ans = 0
    for _ in range(n):
        lst = list(map(int, input().split( )))
        students.append(lst)
    for i in range(n - 1):
        for j in range(i + 1, n):
            if (-5 <= students[i][0] - students[j][0] <= 5) and (-5 <= students[i][1] - students[j][1] <= 5) and (-5 <= students[i][2] - students[j][2] <= 5) and (sum(students[j]) - sum(students[i]) <= 10):
                ans += 1
    print(ans)
    

           \ \ \ \ \ \ \ 但是C++的过了。麻。

    #include<cstdio>
    #include<cmath>
    
    const int MAXN = 1010;
    
    struct Stu{
    	int chinese, math, english;
    }students[MAXN];
    
    int main(){
    	int n, ans;
    	scanf("%d", &n);
    	for(int i = 1; i <= n; i++){
    		scanf("%d %d %d", &students[i].chinese, &students[i].math, &students[i].english);
    	}
    	for(int i = 1; i <= n; i++){
    		for(int j = i + 1; j <= n; j++){
    			if((abs(students[i].chinese - students[j].chinese) <= 5) && (abs(students[i].math - students[j].math) <= 5) && (abs(students[i].english - students[j].english) <= 5) && (abs(students[i].chinese - students[j].chinese + students[i].math - students[j].math + students[i].english - students[j].english) <= 10)){
                    ans ++;
                }
    		}
    	}
        printf("%d", ans);
    	return 0;
    }
    
    • 0
      @ 2026-4-13 10:50:47

      为什么python过不了?

      • 0
        @ 2025-12-5 10:22:34
        #include <stdio.h>
        int main(){
        	int n;
        	scanf("%d",&n);
        	int arr[n][3];
        	int total[n];
        	for(int i=0;i<n;i++){
        		scanf("%d %d %d",&arr[i][0],&arr[i][1],&arr[i][2]);
        		total[i]=arr[i][0]+arr[i][1]+arr[i][2];
        	}
        	int count=0;
        	for(int i=0;i<n;i++){
        		for(int j=i+1;j<n;j++){
        			int a1,a2,a3,a4;
        			a1=arr[i][0]-arr[j][0];
        			a2=arr[i][1]-arr[j][1];
        			a3=arr[i][2]-arr[j][2];
        			a4=total[i]-total[j];
        			if(a1<0){
        			a1=-a1;
        			}
        			if(a2<0){
        			a2=-a2;
        			}
        			if(a3<0){
        			a3=-a3;
        			}
        			if(a4<0){
        			a4=-a4;
        			}
        			if(a1<=5&&a2<=5&&a3<=5&&a4<=10){
        				count++;
        			}
        			
        			
        		}	
        	}
        	printf("%d",count);
        	return 0;
        }
        
        • 0
          @ 2025-11-8 0:16:32
          #include <stdio.h>
          struct Students
          {
              int Chain;
              int Mach;
              int English;
              int All;
          };
          int search(struct Students a[],int n)
          {
              int m=0;
              for(int i=0;i<n;i++)
              {
                  for(int k=0;k<n;k++)
                  {    
                      int A,B,C,D;
                      if(k==i){continue;}
          
                      A=a[i].All-a[k].All;
                      B=a[i].Mach-a[k].Mach;
                      C=a[i].Chain-a[k].Chain;
                      D=a[i].English-a[k].English;
          
                      if(A>=-10&&A<=10)
                      {
                          if(B>=-5&&B<=5)
                          {
                              if(C>=-5&&C<=5)
                              {
                                  if(D>=-5&&D<=5)
                                  {
                                      m++;
                                  }
                              }
                              
                          }
                          
                      }
                      
                  }
              }
              return m;
          }
          int main()
          {
              struct Students a[1001];
              int n;
              scanf("%d",&n);
              for(int i=0;i<n;i++)
              {
                  scanf("%d %d %d",&a[i].Chain,&a[i].Mach,&a[i].English);
                  a[i].All=a[i].Chain+a[i].Mach+a[i].English;
              }
              printf("%d",search(a,n)/2);
              return 0;
          }
          
          • 0
            @ 2024-11-19 19:56:39

            #include<stdio.h>

            #include<math.h>

            typedef struct student{

            int a;

            int b;

            int c;

            }STU;

            int main(){

            int n;

            scanf("%d",&n);

            STU ai[n];

            for(int i=0;i<n;i++){

            scanf("%d %d %d",&ai[i].a,&ai[i].b,&ai[i].c); }

            int find = 0;

            for(int i=0;i<n;i++){

            for(int k=i+1;k<n;k++){

            int sum = (ai[i].a+ai[i].b+ai[i].c)- (ai[k].a+ai[k].b+ai[k].c);

            if(abs(ai[i].a-ai[k].a)<=5&&abs(ai[i].b-ai[k].b)<=5&&abs(ai[i].c-ai[k].c)<=5&&abs(sum)<=10) {

            find++;

            }

            }

            }

            printf("%d",find);

            return 0;

            }

            • 1

            信息

            ID
            98
            时间
            1000ms
            内存
            256MiB
            难度
            6
            标签
            (无)
            递交数
            866
            已通过
            235
            上传者