## Quadratic Sieve: How to find the first number divisible by the element from the Factor Base?

The number to be factored is $$N$$.

Steps

• Create the factor base. Let it be List $$FB = {p1, p2, p3, p4, …}$$

• Generate a list which needs to be sieved down. Let this be List $$L = {x1, x2, x3, x4….}$$

• The quadratic polynomial we are using is $$f(x) = x^2 – N$$
It’s trivially proved that if $$f(x) pmod p1 equiv 0$$, then $$f(x + kp1) pmod p1 equiv 0$$

• Starting with $$p1$$, solve $$x^2 – N equiv 0 pmod p1$$

• If we find a number(root) $$x0$$ as the solution of the above, then it’s divisible by $$p1$$ & $$(x0+p1, x0+2p1, x0+3p1..)$$ are also divisible by $$p1$$. So we can sieve the List L using this.

I understood up to this much.

However, once we reach this stage, how does one find the first number in List $$L$$ which is divisible by $$p1$$? Do we need to go trying $$x1, x2, x3$$ etc by trial division till we find the first one divisible by $$p1$$? Once I find it, then other numbers like $$x1 + p1, x1 + 2p2$$ etc can easily be found without further division.

However, is going through the List $$L$$ by trial division the way to find the first one or is there a better way which I am missing?

Posted on

## unity – Checking if a base class type is of child class and accessing properties

I’m working on an inventory system similar to the Resident Evil games for a game jam. I wanted to practice using a little bit of inheritance, as well as `ScriptableObjects` as data containers, but I’m afraid I might have programmed myself into a corner.

I first declared an Item class

``````(CreateAssetMenu(fileName = "New Item", menuName = "Items/Item"))
public class Item : ScriptableObject
{
public string itemName = "Default Item";
public string itemDescription = "An item.";
public string itemID = "00";
public int quantity = 1;

public Sprite itemIcon;

public bool isStackable = false;

public static int idCounter = 0;

public enum ItemTypes
{
Health,
Puzzle,
Key,
Weapon,
Ammo
};

ItemTypes itemType;
}
``````

and I derived an `Ammo` subclass among others, which has an extra `AmmoType enum`. At some point in my inventory code, I have an `AddToInventory(Item item)` method that takes an `Item` and adds it to a `playerInventory` list.

I’m now trying to stack ammo instead of adding to a new slot, so I was intending to check if the item about to be added has the same `AmmoType` by running through the list. Something like this pseudocode:

``````void AddToInventory(Item item)
{
foreach (Item i in playerInventory)
{
if ((Ammo)item.itemType == (Ammo)i.itemType)
{
// Stack bullets
}
}
}
``````

Of course, it’s not possible to cast like this. Is there any other way to check for the argument’s properties, assuming it is of a certain subclass?

Posted on

## C# / Unity : how to use in a child class a variable created in a base class?

I’m just starting to learn C# and I have a very basic problem regarding classes and inheritance. Basically, I have created a Plant class the regroups the basic functionnalities of a plant, and then I created a Grass class that will be attached to a Grass object in my game.
And I wanted to be able to intialize some variables (like age or birthTime) in the Plant class, and then access them in the Grass class; like this, when I will create another type of plant (flower for example), I would not need to initialize these caracteristics.

Here is my Plant class, where I initialize the age and birthTime variables: And here is my Grass class, where I would want to access these variables but I can’t to it… Could someone explain to me how to do it pls? Thanks!! ## Que base de datos usar en un sistema c# a la que acceden varias pc?

Tengo una aplicacion escritorio hecha en c# usa entity framework y ahora esta funcionando con sql server de manera local, pero quiero que la aplicacion se instale en varias pc que accedan a la misma base de datos. Tengo que guardar imagenes asi que deberia permitir mas o menos 20gb de almacenamiento. ¿Que base de datos puedo usar en este caso?

## base conversion – What does it mean when asking to Convert 16-bit binary numbers to two 8-bit signed integers (two’s complement) in decimal

The question is

Convert the following 16-bit binary numbers to two 8-bit signed
integers (two’s complement) in decimal.

i. 0b 0011 0110 1101 0100

I first flipped it and added 1 to it which equaled

0b 1100 1001 0011 1100 which is 51516 in decimal

Is this right? I don’t really understand what the question is asking for when it says “two” 8-bit signed integers (two’s complement) in decimal.

Posted on

## inheritance – How to create inherrited copy constructor in c++, with a base class object in the parameter

Im new to c++ from java, i wanted to know what im doing wrong i would like to create

I wanna create a copy constructor in my derived class (MOTORCYCLE) that takes base class object parameter Vehicle then use the vehicle vector holding my desired object to pass those values in the constructor

everytime i do it i just get the EMPTY variable i made

``````Motorcycle::Motorcycle(const Vehicle &t,string outDate,double cost,int daysOut )
{
this->t = t;
this->outDate = outDate;
this->cost = cost;
this->daysOut= daysOut;
}
``````

THEN i wish to call that member
like so

`````` class Motorcycles motorcycle(VehicleVector(2).getTitle(),"05-07-1997",5.0,8);
``````
``````

WORKING JAVA EXAMPLE:

public Motorcycle(Vehicle T, String Group, int RPM) {
super(T);
this.Grupo = Grupo;
this.RPM = RPM;

}
``````

Posted on

## Is LibreOffice Base (with its internal database engine) a good replacement for a very old FileMaker?

I have a relatively simple database, constructed in a very old version of FileMaker (old enough that it runs on a G4 “bionic desk lamp” iMac.

I’m looking at alternatives that will run on my new Linux box. LibreOffice Base caught my attention. Will it do at least everything FileMaker does?

Posted on

## base de datos – Deseo realizar un Update con un campo de una tabla como variable. (Sqllite – Javascript )

Quiero poder crear un método que me permita actualizar distintos campos de mi tabla SQLlite con el mismo método. Utilizo la variable campo para ir cambiando el campo que deseo actualizar en la tabla específica de la BD.

``````updateTabla = async ({campo,valor,codigo}) => {
return new Promise(async (resolve, reject) => {
const db = SQLite.openDatabase(dbSqlLite, "1.0", "", 1);
try {
db.transaction(function (txn) {
txn.executeSql(
"UPDATE Gestion SET :campo = :valor WHERE Codigo = :codigo",
(campo, valor,codigoAviso),
(tx, res) => {
console.log(
`GESTION ID: \${codigo} actualizada con \${campo}: \${valor}`
);
resolve(true);
},
(error) => {
console.log(
`GESTION ID: \${codigo} actualizada con \${campo}: \${valor} Error:`
);
console.error(error);
}
);
});
} catch (err) {
reject(false);
}
});
``````

}

Quisiera corroborar si es posible hacerlo de esta manera, ya que me despliega un error, pero sin información de donde se encuentra el problema. Y cuando cambio :campo por el texto del nombre del campo (no como variable) si realiza la ejecución.

Posted on

## dnd 5e – Is a Sidekick’s base +2 proficiency bonus already included in their source stat block?

I’m confused by the Sidekick rules in Tasha’s Cauldron of Everything. In the “Gaining a Sidekick Class” section, it says this:

Proficiency Bonus

The sidekick’s proficiency bonus is determined by its level in its class, as shown in the class’s table. Whenever the sidekick’s proficiency bonus increases by 1, add 1 to the to-hit modifier of all the attacks in its stat block, and increase the DCs in its stat block by 1.

So when I’m building a level 1 sidekick, is the listed +2 proficiency bonus considered two instances of “proficiency bonus increases by 1”, or is the creature considered to already have a +2 bonus, and only gets to upgrade attacks and saves once it reaches a proficiency bonus of +3 on the relevant sidekick class table?

As a specific example, a Bandit has a Dexterity bonus of +1 and his two attacks (scimitar and crossbow) both have a +3 bonus, implying a pre-existing proficiency of +2.

So when he becomes a sidekick and gains a level of Expert, do his attacks still have a +3 attack bonus or do they suddenly become +5?

Posted on

## php – ¿Hay alguna base de datos online de investigadores que te permita realizar consultas?

me gustaría saber si hay alguna base de datos a parte de la de DBLP.