地址:http://acm.hdu.edu.cn/showproblem.php?pid=1395题意:给出n,求满足2^x mod n = 1的最小的x。mark:数论题,其实就是求a模m的阶。打素数表敲错变量,1wa。可以水过,但是最好需要知道以下知识。1. 若gcd(a,m)==1,一定存在一个正整数d<m使得a^d == 1 mod m(欧拉定理)。2. 满足条件的最小正整数d记为ord_m(a),叫做a模m的阶。3. 若对于一个正整数a满足(1)gcd(a,m)==1;(2)ord_m(a)==φ(m)(φ(m)表示m的欧拉函数);则a叫做m的一个原根。4. 若gcd(a,m)
转载
2012-02-15 06:49:00
47阅读
动态规划:...翻牌FAFU 1395 动态规划
原创
2021-07-28 14:00:51
84阅读
1 class Solution:
2 def __init__(self):
3 #self.l = []
4 self.count = 0
5
6 def backTrack(self,rating,temp,idx,inc):
7 if inc == 0:#递减
8 if len(te
转载
2020-03-29 12:38:00
20阅读
DescriptionGiven an undirected weighted graph G, you should find one of spanning trees specified as follows.Th
原创
2022-11-10 01:09:19
79阅读
Archie 很显然的换根dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; int son[100001]; int dis[100001]; int n; int a,b; int head[ ...
转载
2021-07-16 17:32:00
114阅读
2评论
#include#include#define N 10char s[N][N][N]={{"***","* *","* *","* *","***"},{" *"," *"," *"," *"," *"},{"***"," *","***","* ","***"},{"***"
转载
2014-05-06 15:57:00
100阅读
2评论
dp[k]用类似于低配版的这道题的做法求出,如下; 然后就从k逆推到0就好了 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int MX = 105; 4 double dp[MX]; 5 int x[MX]; 6 int main
转载
2019-09-30 19:36:00
107阅读
2评论
题目链接:点我 题意简述求所有生成树中最大边权与最小边权差最小的,输出它们的差值。按照并查集生成最小生成树的思路,将
原创
2022-11-09 14:43:09
50阅读
2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15810 Accepted Submission(s): 4914
原创
2021-07-21 15:35:00
111阅读
There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the
转载
2020-04-16 08:00:00
122阅读
2评论
1.安装ubuntu 14.04.05 LTS 64bit 2.初始化root 密码 sudo passwd Password: < 输入安装时那个用户的密码 Enter new UNIX password: < 新的Root用户密码 Retype new UNIX password: < 重复新的 ...
转载
2021-10-13 16:30:00
71阅读
2评论
题意:给一个n结点的图,求最大边减去最小边尽量小的生成树思路:首先把边的权值从onst int maxn = 100+10;const int
原创
2023-06-09 18:33:37
25阅读
欧拉定理 就是a和m互质,且a小于m,设x为欧拉函数的值,则a^x%m=1恒成
原创
2023-02-07 05:00:21
75阅读
DescriptionThere are n soldiers standing in a line. Each soldier is assigned a unique rating value.You have
原创
2022-08-11 17:48:27
178阅读
【题意】 求一颗生成树,满足最大边和最小边之差最小 InputThe input consists of multiple datasets, followed by a line containing two zeros separated by a space.Each dataset has
转载
2016-11-01 21:20:00
187阅读
2评论
题目链接:https://vjudge.net/problem/LightOJ-1395 1395 - A Dangerous Maze (II) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Y
转载
2018-03-02 16:57:00
89阅读
2评论
There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the
转载
2020-11-03 13:04:00
78阅读
2评论
题目地址:点击打开链接
思路:n为偶数肯定不行,因为2的n次方是偶数,偶数对偶数取模肯定是偶数,1也不行,剩余的奇数都行,因为每个除1的奇数都有一个比他们大1的偶数,对他们取余正好为1
AC代码:
#include
using namespace std;
int main()
{
int n,x,sum;
while(cin>>n)
{
if(n%2 == 0 || n =
原创
2022-08-04 09:10:02
49阅读
hdu 1395 2^x mod n = 1Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11835 Accepted Submission(s): 3684Problem DescriptionGi
原创
2022-12-02 00:29:26
51阅读
2^x mod n = 1Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6543Accepted Submission(s): 1961Problem DescriptionGive a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.InputOne positive integer on each line, the value of n.OutputIf
原创
2021-07-29 16:26:11
110阅读