【 Problem description 】 Your friend suggested playing a game : Will be written with numbers n Put the paper in your pocket , You can draw pieces of paper from your pocket three times , Every time you write down the number on the piece of paper, put it back in your pocket , If the sum of these three numbers is m, You win , Or your friend will win . Please write a program , Judge when the number written on the piece of paper is k1,k2,…,kn Whether the sum of three times of extraction is m Scheme of . 

【 Input form 】 The first line of input is a positive integer  n  Indicates the number of pieces of paper in the pocket (int type ) The second line is a positive integer that represents the sum of three numbers   Third behavior n An integer represents the number on each piece of paper (int type )

【 Output form 】 If there is a satisfactory scheme , output Y, otherwise , output N.

【 sample input 】



 2 3 5

【 sample output 】


Problem solving analysis : The triple cycle of violence leads directly to
import java.util.Scanner; public class p1 { public static void main(String[]
args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m =
sc.nextInt(); int [] arr = new int[n]; for(int i = 0; i < n; i++) arr[i] =
sc.nextInt(); int flag = 0; for(int i = 0; i < n-2; i++) { for(int j = 1; j <
n-1; j++) { for(int k = 2; k < n; k++) { if(arr[i] + arr[j] + arr[k] == m) {
flag = 1; break; } } } } if(flag == 1) System.out.println("Y"); else
System.out.println("N"); } }

©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?