2417专题

POJ 2417 Discrete Logging (求解模方程a^x≡b(mod n))

本题题意很明确,要求解一个解模方程a^x≡b(mod n),这里博主采用了大步小步算法,也就是B-S-G-S算法 代码如下 #include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <cstdlib>#include <string>#inc

Poj 2417 Discrete Logging —— BSGS模板

This way 题意: 告诉你B,N,P,让你求最小的L使得 题解: BSGS模板,大致意思是将L变成ax+b的形式,定下x之后,式子就变成了这样: B b = = N B − a x ( m o d P ) B^b==NB^{-ax}(mod P) Bb==NB−ax(modP) 那么我们只需要先枚举b(0<=b<=x),将所有值都记下来,再枚举a,同时查询即可。 这道题如果将x

2417: 【PY】【排序】求最大值和最小值

题目描述 任意输入n个整数,把它们的最大值,最小值求出来。 输入 一行n个数,以空格隔开 输出 2行,第一行是最大值,第二行是最小值 样例输入 2 5 7 4 3 样例输出 72 Code: #include<bits/stdc++.h>using namespace std;int main(){int a,max=INT_MIN,min=INT_MAX;while(

[YTU]_2417 C语言习题 字符串长度

Description 写一函数,求一个字符串的长度。在main函数中输入字符串,并输出其长度。 Input 一行字符串 Output 字符串长度 Sample Input t9g(*&WE3@#$fw2adECWEr Sample Output 22#include <iostream>#include <cstring>using namespac

bzoj 3239 poj 2417 BSGS

BSGS算法,预处理出 ϕ(c)−−−−√ \sqrt{\phi(c)}内的a的幂,每次再一块一块的往上找,转移时将b乘上逆元,哈希表里O(1)查询即可 #include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>#include<map>#define LL long lo