当前位置:网站首页>Luogu problem list: [mathematics 1] basic mathematics problems
Luogu problem list: [mathematics 1] basic mathematics problems
2022-07-03 06:11:00 【Master core technology】
(1)P1143 Hexadecimal conversion
java It is very good for binary conversion API, Can achieve unlimited length of any hexadecimal conversion .
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
String s=sc.nextLine();
int m=sc.nextInt();
System.out.println(new BigInteger(s,n).toString(m).toUpperCase());
}
}
(2)P1469 Looking for chopsticks
If you know the knowledge of binary , This problem is not difficult . When XOR is performed on each number , Always leave the single number . But this question is disgusting , Only for 4M Of memory , Its original intention is to prevent using the bucket sorting method to do this problem , But it doesn't consider java It's impossible to be in 4M Make it in memory .
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int res=sc.nextInt();
for(int i=1;i<n;i++) {
res^=sc.nextInt();
}
System.out.println(res);
}
}
(3)P1100 High low swap
This question is to examine the understanding of binary . Put the high 16 Shift to low position , We can put n Move right 16 position , In this way, the high position goes directly to the low position , And the low order is directly because it is less than 0 And removed . Then we move the lower number to the right 16 position , We can easily get the low position by taking the mold . Finally, we add the two converted numbers to get a new number .
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long n=sc.nextInt();
long x=(n>>16)+((n%65536)<<16);
System.out.println(x);
}
}
(4)
边栏推荐
- Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
- MySQL帶二進制的庫錶導出導入
- tabbar的设置
- Alibaba cloud OOS file upload
- 輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
- Yum is too slow to bear? That's because you didn't do it
- 1. 兩數之和
- Kubesphere - build Nacos cluster
- [teacher Zhao Yuqiang] use Oracle's tracking file
- [teacher Zhao Yuqiang] RDB persistence of redis
猜你喜欢
项目总结--04
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
[teacher Zhao Yuqiang] Flink's dataset operator
Understand the first prediction stage of yolov1
The most responsible command line beautification tutorial
Solve the problem of automatic disconnection of SecureCRT timeout connection
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
Kubernetes notes (10) kubernetes Monitoring & debugging
Es remote cluster configuration and cross cluster search
Creating postgre enterprise database by ArcGIS
随机推荐
Leetcode problem solving summary, constantly updating!
项目总结--04
有意思的鼠标指针交互探究
CAD插件的安裝和自動加載dll、arx
[system design] proximity service
Maximum likelihood estimation, divergence, cross entropy
MySQL带二进制的库表导出导入
Installation of CAD plug-ins and automatic loading of DLL and ARX
ODL framework project construction trial -demo
1. Somme des deux nombres
Kubernetes notes (10) kubernetes Monitoring & debugging
The server data is all gone! Thinking caused by a RAID5 crash
1. Sum of two numbers
88. 合并两个有序数组
There is no one of the necessary magic skills PXE for old drivers to install!!!
Migrate data from Amazon aurora to tidb
Mysql database binlog log enable record
智牛股--03
Creating postgre enterprise database by ArcGIS
[teacher Zhao Yuqiang] use the catalog database of Oracle