自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 p1002过河卒

注意马位置可能在边缘,导致确定位置为负。因此棋盘整体横纵坐标+2,规避问题。分解为f[i][j] = f[i-1][j] + f[i][j-1]善用数组解决问题,循环判定马限制的位置。

2023-03-12 09:45:04 39

原创 P1603

关注取值大小,12位长度超INT: 4 * 10^9 需用 Long:10^19。大胆用HashMap/ ArrayList。考虑无数字单词情况,输出0。

2023-03-09 18:55:58 52

原创 RGB2GRAY

rgb2gray code record 上述代码在Windows环境下,fgetc/fputc不能正常工作,原因未知,输出像素一定数量后会全为0。但Linux环境下正常运行。

2022-06-05 23:59:57 655

原创 Luogu p1045

思路:快速幂 + 高精数 快速幂见前帖 注意运算过程中只保留后500位,否则会MLE。 ANS MOD 10^500 求2^P - 1的位数: N = floor(log10(2^n) + 1) = floor(n * log10(2)) + 1) Code: import java.util.Scanner; import java.util.*; import java.io.*; import java.math.*; public class Main { public stat..

2022-05-08 15:33:44 51

原创 Luogu p1249

思路:若干互不相同自然数,通过规律可知: 当N > 5时,将N分解为尽可能多的非1数,所得的乘积最大。e.g. 5 -> 2, 3 6 -> 2, 4 故从2开始累加 2 + 3 + 4 + ..., 但在这种情况下,会出现累加和大于目标数的情况。此时若改变数列后方使之变小则...

2022-05-08 15:26:37 56

原创 Luogu P1803

利用类进行排序: CLASS必为STATIC 因为要被MAIN 调用,STATIC 类只能调用外部STATIC类 CLASS内可以包含多个变量 利用ARRAYS.SORT排序: public static class cmp implements Comparator<exam/*自己创建的类,例子里是exam*/>{ @Override public int compare(exam a, exam b) { if (a...

2022-04-07 21:18:01 47

原创 快排JAVA实现

private static int[] in; //待排数组0位置为空,因为该算法可能出现j小于0 //的情况,预留空间。输入数据时从1开始。 //打乱in的原始顺序,以防N^2 private static void swap(int.

2022-03-28 17:46:26 313

原创 快速幂方法

求:a ^ b 一般算法:计算b次 快速算法: 1. b转换为二进制:e.g. b = 11, 001011 2. 每次判断 b 的最后一位是否为1,若为1,则对应的答案乘上此时二进制代表的次数, 并将b向右移动一位,更新a = a^2 a a^2 a^4 a^8 3.若不为1,则只更新a^2, 移位观察b的下一位,直到b = 0; while (p > 0) { if ((p & 1) == 1) { //与运算,判断是否末位为1 ans.

2022-03-24 18:39:36 54

原创 Scanner

a. the data input must contain a newline character at the end of each line, otherwise the nextLine( ) would keep reading the current line and never end. b. nextLine( ) cannot be used when there' s no data coming in. It will become ENDLESS. (Actually, ev

2022-03-21 19:04:12 52

原创 Luogu1957

The biggest problem is determining the type of first input of each line. Solu: Character.isAlphebet( ) // true for letter Character.isDigit( ) // true for digit After the judge, choose to input the next 2 or 1 integer.

2022-03-21 18:58:32 47

原创 JAVA grammar subtleties

1. In printf,creating anewline using %n rather than \n. 2. cout in C language has a default setting that retains 6 significant numbers.

2022-03-18 20:56:38 64

原创 Luogu P1217

Outline: Output all palindromes, then determine whether it’s a prime or not. Cavets: Prime palindromes have the following features: 1. All palindromes have even digits, e.g. 1221, 111111 etc. are divisible by 11 (except 11 itself), so they’re not prime. 2.

2022-03-16 17:01:22 71

原创 Luogu p1888 GCD最大公约数

Cavets: The most difficult part of it is the fraction reduction process, that is, finding the greatest common divisor(gcd) of the numerator and denominator, and then dividing them using the gcd. Euclidean algorithm: Find the gcd! Basic idea: larger mod sm.

2022-03-11 14:57:04 104

原创 Luogu p2181

Basic idea: Two and only two lines can create an intersection according to the instruction. So it is basically a permutations and combinations question: how many sets of 4 vertex does the graph have? Since the sequence of the 4 vertex won’t affect the fin.

2022-03-10 20:14:06 94

原创 Luogu p5705

Luogu p5705 输入一个不小于 100100 且小于 10001000,同时包括小数点后一位的一个浮点数,例如 123.4123.4 ,要求把这个数字翻转过来,变成 4.3214.321 并输出。 CODE: import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String input = sc.next

2022-03-08 13:35:08 160

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除