蓝桥杯(3.7)

P1102 A-B 数对

java 复制代码
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[] res = new int[n+1];
		for(int i=1;i<=n;i++)
			res[i] = sc.nextInt();
		int sum = 0;
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=n;j++) {
				if((res[i]-res[j]) == c) {
					sum++;
				}
			}
		}
		System.out.println(sum);
	}
}
相关推荐
小裕哥略帅3 分钟前
Spring AOP 实现通用 Token 自动刷新重试工具包
java·后端·spring
Lenyiin7 分钟前
第6篇_Python高级语法与标准库精髓:从会用到达精通
java·python·html
YHHLAI10 分钟前
TypeScript 面试题:type 与 interface 的区别与相同点
java·ubuntu·typescript
咖啡八杯15 分钟前
PageHelper 分页封装:TableDataInfo 与 startPage() 的工作原理
java·spring boot·分页·若依·开源框架·pagehelper
多敲代码防脱发17 分钟前
Alibaba Sentinel(熔断、限流)(国内下载Sentinel)
java·开发语言·sentinel
CIO4020 分钟前
AI未来--IT人面试36计
人工智能·面试·职场和发展
.Hypocritical.21 分钟前
【SpringBoot】配置文件加载位置与优先级详解
java·spring boot·后端
JAVA面经实录9171 小时前
RabbitMQ 完整面试题答案
java·rabbitmq·java-rabbitmq
xcl09258 小时前
商超智能运营实战:数据驱动提升门店效率与体验指南
java·mfc·宠物