蓝桥杯(3.6)

小明 2025-05-05 07:21:09 4

1221. 四平index.php/tags-41973.html" class="superseo">���和

()
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i*i 
			for(int j=i;i*i + j*j 
				for(int k=j;i*i + j*j + k*k 
					int t1 = n-i*i-j*j-k*k;
					int t2 = (int)Math.sqrt(t1);
					if(t1 = k*k && t2*t2 == t1) {//加上t1 = k*k
						System.out.println(i+" "+j+" "+k+" "+t2);
						return ;
					}
				}
			}
		}
	}
}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List
			for(int d=c;c*c+d*d
				list.add(new int[] {c*c+d*d,c,d});
			}
		}//2
		
		list.sort(new Comparator
			public int compare(int[] o1, int[] o2) {
				if(o1[0]!=o2[0])
					return o1[0]-o2[0];
				if(o1[1]!=o2[1])
					return o1[1]-o2[1];
				return o1[2]-o2[2];
			};
		});//3
		
		for(int a=0;a*a
			for(int b=a;a*a+b*b
				int t = n-a*a-b*b;
				//二分
				int l = 0,r = list.size()-1;
				while(l
					int mid = (l+r)/2;
					if(list.get(mid)[0] = t)	r = mid;
					else	l = mid+1;
				}
				//l或者r
				if(list.get(l)[0] == t) {
					int c = list.get(l)[1];
					int d = list.get(l)[2];
					System.out.println(a+" "+b+" "+c+" "+d);
					return ;
				}
			}
		}
		
	}
}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map
			for(int d=c;c*c+d*d
				Integer cd = c*c + d*d;
				if(map.get(cd) == null)
					map.put(cd,new int[] {c,d});
			}
		}//2
		
		for(int a=0;a*a
			for(int b=a;a*a+b*b
				Integer t = n-a*a-b*b;
				if(map.get(t) != null) {
					int c = map.get(t)[0];
					int d = map.get(t)[1];
					System.out.println(a+" "+b+" "+c+" "+d);
					return ;
				}
			}
		}
		
	}
}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] res = new int[n+1];
		int[] a = new int[n+1];
		for(int i=1;i
			a[i] = a[i-1] + res[i];
		}
		
		while(m-- != 0) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(a[r]-a[l-1]);
		}
	}
}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[][] a = new int[n+1][m+1];
		int[][] b = new int[n+1][m+1];
		
		for(int i=1;i
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			System.out.println(b[x2][y2]-b[x2][y1-1]-b[x1-1][y2]+b[x1-1][y1-1]);
		}
	}
}
The End
微信