社区讨论

求助,输出例子是对的,为啥全红?

P5728【深基5.例5】旗鼓相当的对手参与者 3已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m2m3wxnl
此快照首次捕获于
2024/10/24 00:46
去年
此快照最后确认于
2025/11/04 16:23
4 个月前
查看原帖
CPP
package luogu;
import java.util.Scanner;
public class P5728旗鼓相当的对手 {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=0;
        int n=sc.nextInt();
        int[] yu=new int[n];
        int[] shu=new int[n];
        int[] ying=new int[n];

        for(int i=0;i<n;i++){
            yu[i]=sc.nextInt();
            shu[i]=sc.nextInt();
            ying[i]=sc.nextInt();
        }

        for(int j=0;j<n-1;j++){
            if(Math.abs(yu[j]-yu[j+1])<=5&&
                    Math.abs(shu[j]-shu[j+1])<=5&&
                    Math.abs(ying[j]-ying[j+1])<=5&&
                    Math.abs((yu[j]+shu[j]+ying[j])-(yu[j+1]+shu[j+1]+ying[j+1]))<=10){

                t++;
            }
        }

System.out.println(t);

    }
}

回复

3 条回复,欢迎继续交流。

正在加载回复...