数学方法
板子题为主
我不是手机
这个作者很懒,什么都没留下…
展开
-
筛法 V - 一道水题
一天,szb 在上学的路上遇到了灰太狼。灰太狼:帮我们做出这道题就放了你。szb:什么题?灰太狼:求一个能被 [1,n] 内所有数整除的最小数字,并对 100000007 取模。szb:这题太水了,就让我小弟来做好了。然后你就光荣的接受了这个任务。Input一行一个数 n。Output一行一个数 ans。Example样例输入10样例输出2520Hintn≤108#include<stdio.h>#include<stdlib.h>#includ原创 2020-07-23 08:59:52 · 121 阅读 · 0 评论 -
筛法 U - Goldbach‘s Conjecture
In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:Every even number greater than 4 can bewritten as the sum of two odd prime numbers.For example:8 = 3 + 5. Both 3 and原创 2020-07-22 19:14:34 · 79 阅读 · 0 评论 -
筛法 T - Max Factor
To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1…20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as better than others. In p原创 2020-07-22 19:12:43 · 94 阅读 · 0 评论 -
筛法 S - Farey Sequence
The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 = {1/2}F3 = {1/3, 1/2, 2/3}F4 = {1/4, 1/3, 1/2, 2/3, 3/原创 2020-07-22 19:12:02 · 87 阅读 · 0 评论 -
矩阵快速幂 K - A Simple Math Problem
Lele now is thinking about a simple function f(x).If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);And ai(0<=i<=9) can only be 0 or 1 .Now, I will give a0 ~ a9 and two positive integers k and原创 2020-07-22 11:17:33 · 75 阅读 · 0 评论 -
矩阵快速幂 J - Fibonacci
In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alternative formula for the Fibonacci sequence is.Given an integ原创 2020-07-22 11:16:52 · 102 阅读 · 0 评论 -
矩阵快速幂 I - Tr A
A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。Input数据的第一行是一个T,表示有T组数据。每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据。接下来有n行,每行有n个数据,每个数据的范围是[0,9],表示方阵A的内容。Output对应每组数据,输出Tr(A^k)%9973。Sample Input22 21 00 13 999999991 2 34 5 67 8 9原创 2020-07-22 11:16:04 · 90 阅读 · 0 评论 -
拓展欧几里得 H - The Balance
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg weig原创 2020-07-22 10:50:39 · 119 阅读 · 0 评论 -
拓展欧几里得 G - Line
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.InputThe first line contains t原创 2020-07-22 10:49:24 · 77 阅读 · 0 评论 -
拓展欧几里得 F - 青蛙的约会
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。我们把这两只青蛙分别叫做青蛙A和青蛙B,并且原创 2020-07-22 10:45:05 · 84 阅读 · 0 评论 -
逆元 E - A/B
要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。Output对应每组数据输出(A/B)%9973。Sample Input21000 5387 123456789Sample Output79226060#include<stdio.原创 2020-07-15 19:19:43 · 342 阅读 · 0 评论 -
费马小定理 D - Sum
Input2Output2#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#include<queue>#include<map>#include<cstdio>#include<vector>#i.原创 2020-07-15 19:18:49 · 145 阅读 · 1 评论 -
费马小定理 C - Dream
Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation (m+n)p=mp+np, where m,n,p are real numbers. Let’s call it ``Beginner’s Dream’’.For instance, (1+4)2=52=25, but 12+42=17≠25.原创 2020-07-15 19:17:35 · 302 阅读 · 1 评论 -
快速幂 B - Rightmost Digit
Given a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Each test case contains a sing原创 2020-07-15 19:13:54 · 89 阅读 · 0 评论 -
快速幂 A - A sequence of numbers
Xinlv wrote some sequences on the paper a long time ago, they might be arithmetic or geometric sequences. The numbers are not very clear now, and only the first three numbers of each sequence are recognizable. Xinlv wants to know some numbers in these sequ原创 2020-07-15 19:11:58 · 72 阅读 · 0 评论