/**
* 获取bigdicmal的长度
* @param number 需要截取的数字
* @param num 需要保留小数点后的位数
* @return
*/
public static int checkBigDecimalLength(String number ,int num){
String s = getSupString(number,num);
return s.length();
}
/**
* 补充后面数值0
* @param number 需要截取的数字
* @param num 需要保留小数点后的位数
* @return
*/
@NotNull
private static String getSupString(String number,int num) {
String s = "";
// 判断是整数还是小数,如果是整数,则小数点后用0补位
if (!number.contains(".")) {
String b = ".";
for (int a = 0; a < num; a++) {
b = b + "0";
}
System.out.println("q111:" + number + b);
s = number + b;
} else {
s = number;
}
return s;
}
public static void main(String[] args) {
BigDecimal num = new BigDecimal("1111111");
System.out.println("num:"+num);
String number = num.toString();
System.out.println("q:"+number);
System.out.println("测试111:"+number.length());
String s = "";
// 判断是整数还是小数,如果是整数,则小数点后用0补位
if (!number.contains(".")) {
String b = ".";
for (int a = 0; a < 8; a++) {
b = b + "0";
}
System.out.println("q111:" + number + b);
s = number + b;
} else {
s = number;
}
System.out.println("测试s:"+ s);
System.out.println("测试s:"+ s.length());
}
下面是我写过的一个pytorch_lightning项目的代码框架。关键代码已经省略。
模型构建
import pytorch_lightning as pl
from pytorch_lightning.plugins.io import TorchCheckpointIO as tcio
import torch
from torch import nn
import torch.nn.functional as F
from torch.…
文章目录 A - Water Station(模拟)B - ABCDEFG(模拟)C - Snuke the Cookie Picker(模拟、暴力)D - Sleep Log(二分,前缀) A - Water Station(模拟)
题意:在[0,100]所有 x % 5 0的地方设置一个水站&#x…