按照key值升序输出: #include<iostream> using namespace std; #include<map> int main() { map<int,int>m; int n; cin >> n; while(n--) { int a = 0, b = 0; cin >> a ...
                            
                            
                                分类:
其他好文   时间:
2021-04-10 13:21:54   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    int func(int n){ int i = 0,sum = 0; while(sum < n) sum += ++i; return i; } 求时间复杂度 A. O(logn) B. O(n^1/2) C. O(n) D. O(nlogn) ++i, i = 1,2,3,4,5,···,k。 ...
                            
                            
                                分类:
其他好文   时间:
2021-04-10 13:08:02   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    做一个多功能计算器 欢迎使用计算器系统 int + int double + double 、 计算 n 的阶乘 计算 a的 n次方、 退出系统 import java.util.Scanner; public class Calculator { public static void main(S ...
                            
                            
                                分类:
编程语言   时间:
2021-04-09 12:50:24   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                long long myPow(long long x, int n) { long long ans = 1; while(n){ if(n % 2 != 0){ ans *= x; ans %= modN; } x *= x; x %= modN; n /= 2; } return ans; } ...
                            
                            
                                分类:
其他好文   时间:
2021-04-08 13:55:01   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    方式一(将整数转换为字符串,在转换为字符数组): public boolean isPalindrome(int x) { if (x < 0) { return false; } char[] chars = new String(Integer.toString(x)).toCharArray( ...
                            
                            
                                分类:
其他好文   时间:
2021-04-08 13:10:24   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    二叉树——102. 二叉树的层序遍历 题目: 思路: 就是层序遍历,一层层扫下去,然后通过队列去实现,一个队列先暂存这一层的所有结点,然后另一个队列通过push_back的方式,实现从左到右的访问。 代码: class Solution { public: vector<vector<int>> l ...
                            
                            
                                分类:
其他好文   时间:
2021-04-08 12:59:26   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    比较for和while 代码比较复制代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 public class HelloWorld { public static void main(String[] args) { //使用while打印0到4 int i =  ...
                            
                            
                                分类:
其他好文   时间:
2021-04-08 12:54:22   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    package com.easyagu.liwei.list;import redis.clients.jedis.Jedis;/** * 秒杀案例 */public class SeckillDemo { public static void main(String[] args) { Secki ...
                            
                            
                                分类:
其他好文   时间:
2021-04-07 11:07:01   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                class Solution { public: int searchInsert(vector<int> &nums, int target) { int low = 0; int high = nums.size() - 1; //为了严谨 <= while (low <= high) { in ...
                            
                            
                                分类:
其他好文   时间:
2021-04-07 10:57:40   
                                阅读次数:
0
                             
                    
                        
                            
                            
                                
                    关于此题有一种精简的写法。 首先我们分析题面,可以发现如果最后可以达到使 \(1\) 到 \(n\) 的路径距离都相等,那么从 \(1\) 到任意一个 \(1\) 到 \(n\) 的路径上的节点的路径也都相等。所以我们设 \(dis[u]\) 为 \(1\) 到 点 \(u\) 的路径长度,\(di ...
                            
                            
                                分类:
其他好文   时间:
2021-04-07 10:37:30   
                                阅读次数:
0