
数论题
m悟空
这个作者很懒,什么都没留下…
展开
-
点到线段的距离
// 设线段两段点A(x1,y1) B (x2 , y2) 设顶点 C ( x , y );double cn(double x,double y,double x1,double y1,double x2,double y2){ double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1); // |AB| * |A...原创 2018-09-23 15:49:02 · 4559 阅读 · 2 评论 -
Mathematically Hard(小于n且与n互质的数的个数==欧拉函数,欧拉表)
Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable.In this problem, you will be given two integersaandb. You have to find the summatio...原创 2019-04-09 08:38:18 · 351 阅读 · 0 评论 -
Eight (八数码 + 康拓展开式)
The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed...原创 2019-04-09 16:11:16 · 793 阅读 · 2 评论 -
Eid (n个数的LCM + 高精度乘法)
In a strange planet there arenraces. They are completely different as well as their food habits. Each race has a food-eating period. That means theithrace eats after everyxide-sec(de-sec is the...原创 2019-04-09 16:20:05 · 399 阅读 · 0 评论 -
Counting Divisors (区间内每个数的因子个数的平方和)
In mathematics, the functiond(n)d(n)denotes the number of divisors of positive integernn.For example,d(12)=6d(12)=6because1,2,3,4,6,121,2,3,4,6,12are all1212's divisors.In this problem, gi...原创 2019-04-09 16:44:19 · 536 阅读 · 0 评论 -
Trailing Zeroes (II) (求末尾0的个数)
Find the number of trailing zeroes for the following function:nCr* pqwheren, r, p, qare given. For example, ifn = 10, r = 4, p = 1, q = 1, then the number is210so, number of trailing zeroes ...原创 2019-04-09 17:33:18 · 271 阅读 · 0 评论 -
Wand (组合数 + 逆元 + 错排公式)
N wizards are attending a meeting. Everyone has his own magic wand. N magic wands was put in a line, numbered from 1 to n(Wand_i owned by wizard_i). After the meeting, n wizards will take a wand one b...原创 2019-04-09 17:47:48 · 951 阅读 · 0 评论 -
组合数模板(卢卡斯 + 扩展卢卡斯)
求 C(n,m) %p的结果。当n太大时,我们无法打阶乘表,所以我们采用Lucas定理来求组合数。一 n , m ,mod 较大,mod为素数例题:mod<=1e9,n<=1e9, m<=1e4#include <iostream>#include <cstdio>#define LL long longusing names...原创 2019-04-09 19:49:30 · 283 阅读 · 0 评论 -
Triangle(给了一系列数,判断能不能选出三个数构成三角形)
Problem DescriptionAfter Xiaoteng took a math class, he learned a lot of different shapes, but Xiaoteng's favorite triangle is because he likes stable shapes, just like his style.After the Xiaoxun...原创 2019-04-21 16:17:45 · 1271 阅读 · 2 评论 -
Catalan Square (卡特兰数 大数)
Last weekend you and your friends went to visit the local farmer’s market at the town square. As you were standing around in a circle talking, you couldn’t help overhearing two of your friends musing ...原创 2019-04-17 09:27:54 · 737 阅读 · 0 评论 -
Opening Ceremony (贪心)
For the grand opening of the algorithmic games in NlogNsglow, a row of tower blocks is set to be demolished in a grand demonstration of renewal. Originally the plan was to accomplish this with control...原创 2019-04-17 10:02:52 · 553 阅读 · 0 评论 -
Counting Divisors (区间因子个数之和,区间打表)
In mathematics, the functiond(n)d(n)denotes the number of divisors of positive integernn.For example,d(12)=6d(12)=6because1,2,3,4,6,121,2,3,4,6,12are all1212's divisors.In this problem, gi...原创 2019-04-30 19:52:38 · 674 阅读 · 0 评论 -
GCD and LCM (素因子分解)
Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L?Note, gcd(x, y, z) means the greatest common d...原创 2019-04-30 20:05:06 · 293 阅读 · 0 评论 -
树状数组解决约瑟夫环
最后剩下的人int Josephus(int n, int k){ if (n<=0 || k<1) throw exception(); if (n==1) return 1;//人为规定,n为1时返回1 int res=k%2;//只有两个人时,返回的人的下标(从零开始计算) for (int i = 3; i <=n; i++) { res =...原创 2019-04-12 11:00:49 · 384 阅读 · 0 评论 -
Super A^B mod C(欧拉降幂)
Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000).InputThere are multiply testcases. Each testcase, there is one line contains th...原创 2019-04-08 09:04:36 · 220 阅读 · 0 评论 -
Intersection (圆环相交的面积,两圆相交面积模板)
Matt is a big fan of logo design. Recently he falls in love with logo made up by rings. The following figures are some famous examples you may know.A ring is a 2-D figure bounded by two circles ...原创 2019-04-11 08:16:13 · 902 阅读 · 0 评论 -
Goldbach`s Conjecture (素数打表)
Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [1]....原创 2018-09-02 21:38:01 · 2066 阅读 · 0 评论 -
A - Bi-shoe and Phi-shoe (素数打表)
Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go...原创 2018-09-02 21:30:00 · 218 阅读 · 0 评论 -
Primes (素数打表)
Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not c...原创 2018-09-02 21:20:56 · 624 阅读 · 0 评论 -
Math(数论-分解素因子)
JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer nn, you can perform the following operations z...原创 2018-11-29 17:49:22 · 750 阅读 · 0 评论 -
折线分割平面 (公式 QAQ..)
我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。 Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。 Output对于每个测试实例,...原创 2018-07-18 20:42:42 · 969 阅读 · 0 评论 -
初中的算术(java大数 高精度)
Noder现在上初三了,正在开始复习中考。他每天要计算型如 (a× a× a× ⋯× a)n个a(a× a× a× ⋯× a)⏟n个a 的式子。 其中 0.0<a<99.999,0<n<260.0<a<99.999,0<n<26 。虽然Noder会计算,但是老是算错,现在他想要你来写一个程序输出正确的结果,以便他核对。输入单组测试数据。...原创 2019-02-15 13:40:18 · 180 阅读 · 0 评论 -
矩阵运算
矩阵 A[r1 * c1 ] * 矩阵 B[ r2 * c2 ]得 矩阵 C [ r1 * c2 ]运算:for(int i=0;i<r1;i++) for(int j=0;j<c2;j++) for(int k=0;k<c1;k++) C[i][j]+=A[i][k]*B[k][j];...原创 2019-02-16 01:48:26 · 582 阅读 · 0 评论 -
数字0-9的数量 (数位dp ,技巧)
给出一段区间a-b,统计这个区间内0-9出现的次数。比如 10-19,1出现11次(10,11,12,13,14,15,16,17,18,19,其中11包括2个1),其余数字各出现1次。 收起输入两个数a,b(1 <= a <= b <= 10^18)输出输出共10行,分别是0-9出现的次数输入样例10 19输出样例11111...原创 2019-02-16 15:46:48 · 1441 阅读 · 0 评论 -
矩阵中不重复的元素 (指数转换成对数,去重)
一个m*n的矩阵。 该矩阵的第一列是a^b,(a+1)^b,.....(a + n - 1)^b第二列是a^(b+1),(a+1)^(b+1),.....(a + n - 1)^(b+1).......第m列是a^(b + m - 1),(a+1)^(b + m - 1),.....(a + n - 1)^(b + m - 1)(a^b表示a的b次方) 下面是一个4...原创 2019-02-16 18:38:00 · 380 阅读 · 0 评论 -
River Hopscotch (二分法)
Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a ro...原创 2019-03-15 13:54:12 · 469 阅读 · 0 评论 -
带劲的and和 (并查集找联通 + 二进制运算)
度度熊专门研究过“动态传递闭包问题”,他有一万种让大家爆蛋的方法;但此刻,他只想出一道简简单单的题——至繁,归于至简。度度熊有一张n个点m条边的**无向图**,第ii个点的点权为vivi。如果图上存在一条**路径**使得点ii可以走到点jj,则称i,ji,j是**带劲**的,记f(i,j)=1f(i,j)=1;否则f(i,j)=0f(i,j)=0。显然有f(i,j)=f(j,i)f(i,j...原创 2019-03-20 21:12:59 · 278 阅读 · 0 评论 -
k倍区间 (模运算 好题)
问题描述 给定一个长度为N的数列,A1, A2, ... AN,如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间。 你能求出数列中总共有多少个K倍区间吗?输入格式 第一行包含两个整数N和K。(1 <= N, K <= 100000) 以下N行每行包含一个整数Ai。(1 <=...原创 2019-03-22 14:57:45 · 335 阅读 · 0 评论 -
糖果传递 (数学+贪心)
题目描述原题来自:HAOI 2008有个小朋友坐成一圈,每人有颗糖果。每人只能给左右两人传递糖果。每人每次传递一颗糖果的代价为。求使所有人获得均等糖果的最小代价。输入格式第一行有一个整数,表示小朋友个数;在接下来行中,每行一个整数。输出格式输出使所有人获得均等糖果的最小代价。样例样例输入41254样例输出4题目...原创 2019-05-15 21:03:56 · 1361 阅读 · 0 评论