当前位置:网站首页>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)
边栏推荐
- Es remote cluster configuration and cross cluster search
- 1. 两数之和
- Apple submitted the new MAC model to the regulatory database before the spring conference
- Leetcode solution - 01 Two Sum
- Kubernetes notes (VI) kubernetes storage
- GPS坐标转百度地图坐标的方法
- Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
- Exportation et importation de tables de bibliothèque avec binaires MySQL
- Mysql database table export and import with binary
- BeanDefinitionRegistryPostProcessor
猜你喜欢

Kubernetes notes (10) kubernetes Monitoring & debugging

Convolution operation in convolution neural network CNN

輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
![[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
![[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system

项目总结--2(Jsoup的基本使用)
![[teacher Zhao Yuqiang] index in mongodb (Part 1)](/img/2d/277ec737f2a7065831a19d036e61e1.jpg)
[teacher Zhao Yuqiang] index in mongodb (Part 1)

Code generator - single table query crud - generator

项目总结--01(接口的增删改查;多线程的使用)

Understand expectations (mean / estimate) and variances
随机推荐
Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
理解 期望(均值/估计值)和方差
Leetcode problem solving summary, constantly updating!
GPS坐标转百度地图坐标的方法
Kubernetes notes (VIII) kubernetes security
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system
Core principles and source code analysis of disruptor
深入解析kubernetes controller-runtime
Synthetic keyword and NBAC mechanism
Analysis of Clickhouse mergetree principle
If function of MySQL
Kubesphere - build MySQL master-slave replication structure
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Loss function in pytorch multi classification
PMP notes
Why is the website slow to open?
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
Installation of CAD plug-ins and automatic loading of DLL and ARX
1. 两数之和
1. Sum of two numbers