7/23 + 7/30 解 zerojudge.tw 中之 a007 判斷質數
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#define maxn 46340
using namespace std;
bool c[maxn+10];
vector <int> p;
// 以下 isp 為函式, 傳入 n 判斷是否為質數
bool isp(int n)
{
if(n<=maxn) return( !c[n] );
int q = (int) sqrt(n);
int k;
for(k=0; k<p.size()...
2015年7月24日 星期五
2015年7月17日 星期五
102年模擬題 (第3題-數學問題:子題1-質因數乘積與最大公因數)
Rem 102年模擬題 Problem3:數學問題 子題1:質因數乘積及最大公因數
Dim p(100) As Integer ' 2 ~ 255=SQRT(65535) 之間的質數,p(0)=2,(1)=3,(2)=5,(3)=7 ....,p(53)=251
Dim pcnt As Integer = 1 '質數表個數
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'建質數表
p(0) = 2 '第1個質數 2
For k = 3 To 255 Step...