
【ACM-数论】
qq_36424540
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Sky Full of Stars CodeForces - 997C
On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.It is well known that one month on this planet consists of n2days, so calendars, represented a...原创 2019-03-18 16:54:18 · 318 阅读 · 0 评论 -
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...原创 2018-08-26 21:38:20 · 205 阅读 · 0 评论 -
洋灰三角
链接:https://www.nowcoder.com/acm/contest/136/J来源:牛客网 题目描述 洋灰是一种建筑材料,常用来筑桥搭建高层建筑,又称,水泥、混凝土。 WHZ有很多铸造成三角形的洋灰块,他想把这些洋灰三角按照一定的规律放到摆成一排的n个格子里,其中第i个格子放入的洋灰三角数量是前一个格子的k倍再多p个,特殊地,第一个格子里放1个。 W...原创 2018-08-19 19:49:49 · 335 阅读 · 0 评论 -
a-贝利福斯数 (各种线性筛)
链接:https://www.nowcoder.com/acm/contest/158/D来源:牛客网 题目描述将所有形如ax+1的数称为a-贝利福斯数,其中x是正整数。一个a-贝利福斯数是a-贝利福斯素数,当且仅当它不能被分解成两个a-贝利福斯数的积。现在给出a,n,问有多少个 ≤ n的a-贝利福斯数可以被分解成两个a-贝利福斯素数的积。输入描述:一行两个数a,n输...原创 2018-08-26 10:44:55 · 234 阅读 · 0 评论 -
GuGuFishtion
转载地址 线性求逆元原理:#include <cstdio>#include <bits/stdc++.h>#include <map>#include <cstring>#include <algorithm>using namespace std;#define mst(a,b) mems...转载 2018-08-18 14:00:51 · 279 阅读 · 0 评论 -
GCD
Problem DescriptionGiven 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may ...原创 2018-08-17 21:02:59 · 561 阅读 · 0 评论 -
Glenbow Museum UVA - 1073
#include<bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)typedef long long ll;bool is_prime(int x){if(x<2)return false;int m=sqrt(x+0.5);rep(i,2,m+1)if(x%i...原创 2018-08-12 21:50:46 · 200 阅读 · 0 评论 -
Exploring Pyramids UVA - 1362
#include<bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)typedef long long ll;bool is_prime(int x){if(x<2)return false;int m=sqrt(x+0.5);rep(i,2,m+1)if(x%i...原创 2018-08-12 20:16:01 · 284 阅读 · 0 评论 -
A Research Problem UVA - 10837 (欧拉函数定义)
原文地址 #include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)const int maxn=1e5+10...原创 2018-08-03 12:52:21 · 292 阅读 · 0 评论 -
Stand in a Line UVA - 11174(递归+有重复元素的全排列) 线性阶乘逆元
#include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)const int maxn=4e4+10;const int...原创 2018-08-07 20:55:37 · 295 阅读 · 0 评论 -
Counting regions
链接:https://www.nowcoder.com/acm/contest/146/G来源:牛客网 题目描述Niuniu likes mathematics. He also likes drawing pictures. One day, he was trying to draw a regular polygon with n vertices. He connected e...原创 2018-08-11 20:02:22 · 235 阅读 · 0 评论 -
GCD - Extreme (II) UVA - 11426
#include<bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)#define bug(x) printf("x:%d****\n",x)typedef long long ...原创 2018-08-14 22:29:50 · 339 阅读 · 0 评论 -
Always an integer UVA - 1069(多项式的差分数列+模拟)
#include<bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)#define bug(x) printf("x:%d****\n",x)typedef long long ...原创 2018-08-14 21:55:27 · 212 阅读 · 0 评论 -
Series-Parallel Networks UVA - 10253
#include<bits/stdc++.h>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)typedef long long ll;const int maxn=40;ll dp[maxn][m...原创 2018-08-14 20:27:14 · 224 阅读 · 0 评论 -
Connected Graph POJ - 1737
An undirected graph is a set V of vertices and a set of E∈{V*V} edges.An undirected graph is connected if and only if for every pair (u,v) of vertices,u is reachable from v.You are to write a program...原创 2018-08-11 10:29:55 · 251 阅读 · 0 评论 -
Cheerleaders UVA - 11806
#include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,a,b) for(int i=a;i<b;i++)#define lrep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i&g...原创 2018-08-02 11:00:45 · 185 阅读 · 0 评论 -
Standard Deviation UVA - 10886(C++输出格式控制+long double类型坑点+方差的两种公式)
所以,我们不必遍历两遍数组,只需要遍历一遍就好了#include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,a,b) for(int i=a;i<b;i++)#define per(i,a,b) for(int i=b-1;i>=a;i--)unsi...原创 2018-07-31 21:14:58 · 326 阅读 · 1 评论 -
Rikka with Ants
链接:https://www.nowcoder.com/acm/contest/148/H来源:牛客网 题目描述There are two small ants on Rikka's desk. If we consider Rikka's desk as a two-dimensional Cartesian coordinate system, both of them have ...原创 2018-08-22 21:52:58 · 399 阅读 · 0 评论 -
Rikka with Stone-Paper-Scissors(全概率公式)
Problem DescriptionDid you watch the movie "Animal World"? There is an interesting game in this movie.The rule is like traditional Stone-Paper-Scissors. At the beginning of the game, each of the tw...原创 2018-08-27 11:09:11 · 367 阅读 · 0 评论 -
Tribles UVA - 11021 (全概率公式)
#include<bits/stdc++.h>using namespace std;typedef long long LL;#define rep(i,a,b) for(int i=a;i<b;i++)const int maxn=1010;double p[maxn],f[maxn];int main(){ int T; scanf...原创 2018-08-27 11:13:50 · 180 阅读 · 0 评论 -
Frogs HDU - 5514
There are m stones lying on a circle, and n frogs are jumping over them.The stones are numbered from 0 to m−1 and the frogs are numbered from 1 to n. The i-th frog can jump over exactly ai stones in ...原创 2018-10-16 13:22:08 · 300 阅读 · 0 评论 -
Count a * b HDU - 5528 (推公式)
Marry likes to count the number of ways to choose two non-negative integers a and b less than m to make a×b mod m≠0.Let's denote f(m) as the number of ways to choose two non-negative integers a and b...转载 2018-10-06 14:16:09 · 236 阅读 · 0 评论 -
Master of Phi HDU - 6265 (推公式)
推公式:1. 把 再往下拆一级,拆到 一级, 复杂度 ,但是得用 实现,要是二进制枚举会重算很多数字2. 直接 积性函数的 性质, 直接把 拆掉,最后把所有的相乘 第一种#include<bits/stdc++.h>using namespace std;typedef long long LL;#define rep(i,a,b) for(i...原创 2018-10-12 16:29:00 · 323 阅读 · 0 评论 -
Jumping frog Gym - 101889J
思维题:一种方案可行,那么 肯定是可行的,然后验证就好了。启示: 貌似超时,实际上,只需要验证 n 的因子就行了,根本就不多。 下次看见gcd(),想想因子,就会很舒服。#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N=1e5+10;char s[N*2...原创 2018-10-04 20:23:24 · 985 阅读 · 0 评论 -
Wannafly挑战赛25 C 期望操作数
链接:https://www.nowcoder.com/acm/contest/197/C来源:牛客网 题目描述Nqijij 有一个数x,和一个神秘权值 q, 满足 x <= q, 每一次nqijij会随机x 变成 [x, q] 中的一个随机数,nqijij想要知道期望多少次操作之后x 变为q。由于nqijij 是一个精力充沛的人,所以他总共会选择 T 次x 和q 进行操作,对...原创 2018-10-02 09:52:56 · 291 阅读 · 3 评论 -
Treblecross UVA - 10561
每个X把区域分成了禁区,也就是说谁先进入必死,因为他下一个,别人就一定会赢,也就是必胜态的位置。也就是我们如果先手,一定要给对手留下一个必败态,这样对方才会输。所以就是枚举一下位置,判断一下NIM和就好了。#include<bits/stdc++.h>using namespace std;typedef long long LL;typedef uns...原创 2018-10-01 19:35:00 · 243 阅读 · 0 评论 -
Puzzled Elena HDU - 5468 (容斥定理+前缀和)
Since both Stefan and Damon fell in love with Elena, and it was really difficult for her to choose. Bonnie, her best friend, suggested her to throw a question to them, and she would choose the one who...原创 2018-09-14 20:29:34 · 247 阅读 · 0 评论 -
Clone HDU - 5000 (Dilworth定理)
After eating food from Chernobyl, DRD got a super power: he could clone himself right now! He used this power for several times. He found out that this power was not as perfect as he wanted. For examp...转载 2018-09-19 10:50:49 · 163 阅读 · 0 评论 -
Walk HDU - 5001
I used to think I could be anything, but now I know that I couldn't do anything. So I started traveling.The nation looks like a connected bidirectional graph, and I am randomly walking on it. It mean...原创 2018-09-18 16:45:35 · 184 阅读 · 0 评论 -
BE, GE or NE (PN 结点)
In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named "Sena" are playing a video game. The game system of this video game is quite unique: in the process of playing th...原创 2018-09-10 17:13:27 · 553 阅读 · 0 评论 -
游戏 (SG函数)
链接:https://www.nowcoder.com/acm/contest/161/B来源:牛客网 题目描述小N和小O在玩游戏。他们面前放了n堆石子,第i堆石子一开始有ci颗石头。他们轮流从某堆石子中取石子,不能不取。最后无法操作的人就输了这个游戏。但他们觉得这样玩太无聊了,更新了一下规则。具体是这样的:对于一堆有恰好m颗石子的石头堆,假如一个人要从这堆石子中取石子,设他要取石子数...原创 2018-09-04 19:47:25 · 285 阅读 · 0 评论 -
bookshelf
Problem DescriptionPatrick Star bought a bookshelf, he named it ZYG !!Patrick Star has N book .The ZYG has K layers (count from 1 to K) and there is no limit on the capacity of each layer !Now Pa...原创 2018-08-29 15:41:44 · 609 阅读 · 0 评论 -
#108. 多项式乘法
题目描述这是一道模板题。输入两个多项式,输出这两个多项式的乘积。输入格式第一行两个整数 n n n 和 m m m,分别表示两个多项式的次数。第二行 n+1 n + 1 n+1 个整数,分别表示第一个多项式的 0 0 0 到 n n n 次项前的系数。第三行 m+1 m + 1 m+1 个整数,分别表示第二个多项式的 0 0 0 到 m m m 次项前的系数。输出格式...原创 2018-08-21 21:00:51 · 398 阅读 · 0 评论 -
Strange Way to Express Integers POJ - 2891 (mod不互素)
Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following: Choose k different positive integers a1, a2, …, ak...原创 2018-08-21 13:03:31 · 140 阅读 · 0 评论 -
Rikka with Badminton
Problem DescriptionIn the last semester, Rikka joined the badminton club.There are n students in the badminton club, some of them have rackets, and some of them have balls. Formally, there are a st...原创 2018-08-20 21:02:28 · 312 阅读 · 0 评论 -
Problem A.Alkane
Multiple query, for each n, you need to getn i-1∑ ∑ [gcd(i + j, i - j) = 1]i=1 j=1InputOn the first line, there is a positive integer T, which describe the number of queries. Next there are T l...原创 2018-08-23 15:01:33 · 376 阅读 · 0 评论 -
Matches UVA - 11375
import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String []args) { final int max=2010; int []c= {6,2,5,5,4,5,6,3,7,6}; BigInteger []dp=new...原创 2018-08-05 10:00:28 · 175 阅读 · 0 评论 -
Binomial coefficients UVA - 1649(枚举+二分)
#include<bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,a,b) for(ll i=a;i<b;i++)#define per(i,a,b) for(ll i=b-1;i>=a;i--)#define ls(x) (x<<1)#define r...原创 2018-08-04 21:31:50 · 292 阅读 · 0 评论 -
历届试题 包子凑数(拓展欧几里得+ 完全背包)
问题描述 小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子。每种蒸笼都有非常多笼,可以认为是无限笼。 每当有顾客想买X个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的...原创 2018-03-08 09:24:31 · 1153 阅读 · 0 评论 -
Probability UVA - 11346
#include<cstring>#include<cstdio>#include<iostream>#include<algorithm>#include<cmath>using namespace std;typedef long long ll;const int maxn=2e5+10;const double ...原创 2018-04-17 15:00:03 · 116 阅读 · 0 评论