一:判定质数 要判断一个数是不是质数,只需遍历小于等于它的所有数,如果它能被除了1和本身之外的数整除,那么它就不是质数。 很简单,暴力枚举,代码如下: 1 bool is_prime(int x) 2 { 3 if (x < 2) return false; 4 for (int i = 2; i  ...
                            
                            
                                分类:
其他好文   时间:
2019-11-28 11:48:52   
                                阅读次数:
80
                             
                    
                        
                            
                            
                                #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5+10; int a[N]; int n; bool prime(int x) {//判断是否为质数 for(int i = 2; ...
                            
                            
                                分类:
其他好文   时间:
2019-11-28 01:33:53   
                                阅读次数:
97
                             
                    
                        
                            
                            
                                    Pairs Forming LCM (LightOJ 1236)【简单数论】【质因数分解】【算术基本定理】(未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of the following code: ...
                            
                            
                                分类:
其他好文   时间:
2019-11-27 12:21:00   
                                阅读次数:
76
                             
                    
                        
                            
                            
                                    题意 https://vjudge.net/problem/CodeForces-1228C 首先先介绍一些涉及到的定义: 定义prime(x)表示x的质因子集合。举例来说,prime(140)={2,5,7},prime(169)={13}。 定义g(x,p)表示存在一个最大的k∈N?,使得x可以 ...
                            
                            
                                分类:
其他好文   时间:
2019-11-26 23:06:30   
                                阅读次数:
124
                             
                    
                        
                            
                            
                                    复杂度 O(N) bool isPrime[1000001]; //isPrime[i] == 1表示:i是素数 int Prime[1000001], cnt = 0; //Prime存质数 void GetPrime(int n)//筛到n { memset(isPrime, 1, sizeof ...
                            
                            
                                分类:
其他好文   时间:
2019-11-24 11:52:07   
                                阅读次数:
65
                             
                    
                        
                            
                            
                                    1145 Hashing - Average Search Time (25 分) The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. ...
                            
                            
                                分类:
其他好文   时间:
2019-11-20 16:57:03   
                                阅读次数:
104
                             
                    
                        
                            
                            
                                alarm_time: [ { required: true, message: "请输入时间", trigger: "blur" }, { validator(rule, value, callback) { if (Number.isInteger(Number(value)) && Numbe ...
                            
                            
                                分类:
其他好文   时间:
2019-11-18 18:23:47   
                                阅读次数:
116
                             
                    
                        
                            
                            
                                例11 求质数 问题描述 质数是指除了有1和自身作为约数外,不再有其他约数的数。比如:3、5、7是质数。而9不是质数,因为它还有约数3。 编写程序求给定区间中的所有质数。 输入格式 两个整数a和b,其中1≤a≤b≤100000。 输出格式 输出给定范围的所有质数,输出时每个质数占5列,每行输出10个 ...
                            
                            
                                分类:
编程语言   时间:
2019-11-18 09:16:56   
                                阅读次数:
91
                             
                    
                        
                            
                            
                                恢复内容 #include<stdio.h> int main() { long int s,p=1,t=0; printf("输入一个整数:"); scanf("%ld",&s); while(s) { if((s%10)%2==1) { t=t+(s%10)*p; p=p*10; } s=s/1 ...
                            
                            
                                分类:
其他好文   时间:
2019-11-17 17:32:56   
                                阅读次数:
67
                             
                    
                        
                            
                            
                                    B. Bear and Compressing 思路:字符串是什么样的有多种情况不定,但我们总是知道最后一个肯定是a,那么我们就可以反着推,看a是由那个序列变过来的,拿案例一的数据说,比如我们先看见ca,可以变成a,那a的上一个状态就是ca,由“ca”代替“a“,此时长度为2,还不够长,所以继续找, ...
                            
                            
                                分类:
其他好文   时间:
2019-11-17 13:13:25   
                                阅读次数:
68