蓝桥杯(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);
	}
}
相关推荐
惜.己4 小时前
Java结合idea简单使用Playwright
java·开发语言·自动化
Vex2une5 小时前
JDK 8 下载安装与环境变量配置完整指南(Windows新手图文教程)
java·windows·环境配置·环境变量·jdk8·jdk下载安装·java入门教程
文丑颜不良啊6 小时前
LeetCode3281~3300题目解析
java·leetcode
nice_lcj5207 小时前
【从零理解计算机网络 · 02】分层模型:别背 OSI 七层,看数据怎么被“打包“和“拆包“
java·后端·tcp/ip·计算机网络·面试·osi·分层模型
SimonKing8 小时前
给Deepseek Harness装上插件市场,从此插件无忧
java·后端·程序员
艾莉丝努力练剑8 小时前
【AI大模型接入SDK】C++的SessionManager 线程安全
java·开发语言·前端·c++·人工智能·学习·安全
aiotto资源分享9 小时前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
RuoyiOffice9 小时前
SpringBoot3+Vue3 采购到付款:ERP、WMS与财务如何按同一来源协同
java·spring boot·架构·vue
文丑颜不良啊10 小时前
LeetCode3261~3280题目解析
java·leetcode
代码不停10 小时前
Spring 原理
java·spring