http://codeforces.com/contest/645/problem/F F. Cowslip Collections time limit per test 8 seconds memory limit per test 512 megabytes input standard input output standard output In an attempt to make peace with the Mischievious Mess Makers, Bessie and…
F - Cowslip Collections http://codeforces.com/blog/entry/43868 这个题解讲的很好... #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define…
题目大意:输入一个整数n,输出使2^x mod n = 1成立的最小值K 解题思路:简单数论 1)n可能不能为偶数.因为偶数可不可能模上偶数以后==1. 2)n肯定不可能为1 .因为任何数模上1 == 0: 3)所以n肯定是除1外的奇数 代码如下: #include <iostream> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n == 1 || n % 2 ==…
[整除] 若a被b整除,即a是b的倍数,那么记作b|a("|"是整除符号),读作"b整除a"或"a能被b整除".b叫做a的约数(或因数),a叫做b的倍数. [质因数分解] 把一个正整数数分解成几个质数的幂相乘的形式叫做质因数分解. e.g. 10=2*5 16=24 18=2*32 [唯一分解定理] 唯一分解定理(算术基本定理)可表述为:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积: N=P1a1*P2a2*P…
传送门 简单数论暴力题. 题目简述:要求求出所有满足x2≡1mod&ThinSpace;&ThinSpace;nx^2\equiv1 \mod nx2≡1modn且0≤x<n0\le x<n0≤x<n的xxx 考虑到使用平方差公式变形. (x−1)(x+1)≡0mod&ThinSpace;&ThinSpace;n(x-1)(x+1)\equiv0 \mod n(x−1)(x+1)≡0modn 即(x−1)(x+1)=kn(x-1)(x+1)=kn(x−1)…
CF 984C Finite or not? (数论) 给定T(T<=1e5)组数据,每组数据给出十进制表示下的整数p,q,b,求问p/q在b进制意义下是否是有限小数. 首先我们先把p/q约分一下.类比一下b=10的情况,我们发现约分后,只有当q的因数仅有2的倍数和5的倍数时,p/q才是有限小数.于是这启发我们猜结论:仅当q的质因数集合包含在b的质因数集合内时,p/q在b进制下才是有限小数. 那么现在问题就被转换为了:已知两数q,b,问q的质因数集合是否完全包含在b的中. 设\(b=p_1^{k…
Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of the following code: long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int j = i; j <= n; j++ ) if( lcm(i, j) ==…
Help Hanzo (LightOJ - 1197) [简单数论][筛区间质数] 标签: 入门讲座题解 数论 题目描述 Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love of Nakurur…
Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first myste…
Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For exam…