【bzoj3239】Discrete Logging 离散对数

我的AI学习 ai维护工具之langfuse as_type: Optional[Literal[‘generation’]] = None, # 将记录定义为 Observation (LLM 调用)transform_to_string: Optional[Callable[[Iterable], str]] = None # 将输出转为 string。要用LangFuse的云服务,首先要在LangFuse官网上注册,注册完后将页面拉倒最后,点免费的SignUp,API文档:https://api.reference.langfuse.com/ 阅读详情

AC通道:http://www.lydsy.com/JudgeOnline/problem.php?id=3239

【吐槽】

这题和【bzoj】2480一毛一样。

就是输入顺序和输出变了一下。

/*************
  bzoj 3239
  by chty
  2016.11.8
*************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<algorithm>
using namespace std;
#define mod 99991
typedef long long ll;
struct node{ll v,num,f;}hash[mod+10];
ll A,B,C;
inline ll read()
{
    ll x=0,f=1;  char ch=getchar();
    while(!isdigit(ch))  {if(ch=='-')  f=-1;  ch=getchar();}
    while(isdigit(ch))  {x=x*10+ch-'0';  ch=getchar();}
    return x*f;
}
ll gcd(ll a,ll b) {return !b?a:gcd(b,a%b);}
void insert(ll v,ll x)
{
    ll t=v%mod;
    while(hash[t].f&&hash[t].v!=v) {t++; if(t>mod) t-=mod;}
    if(!hash[t].f) {hash[t].f=1;hash[t].num=x;hash[t].v=v;}
}
ll find(ll v)
{
    ll t=v%mod;
    while(hash[t].f&&hash[t].v!=v) {t++; if(t>mod) t-=mod;}
    if(!hash[t].f)  return -1;
    else return hash[t].num;
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)  {x=1; y=0; return;}
    exgcd(b,a%b,x,y);
    ll t=x;x=y;y=t-a/b*y;
}
ll Shank()
{
    ll ret=1;
    for(ll i=0;i<=50;i++) {if(ret==B) return i;ret=ret*A%C;}
    ll temp,ans(1),cnt(0);
    while((temp=gcd(A,C))!=1)
    {
        if(B%temp)  return -1;
        C/=temp;  B/=temp;
        ans=ans*(A/temp)%C;
        cnt++;
    }
    ll m=(ll)ceil(sqrt(C*1.0)),t(1);
    for(ll i=0;i<m;i++) {insert(t,i);t=t*A%C;}
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        exgcd(ans,C,x,y);
        ll val=x*B%C;
        val=(val%C+C)%C;
        ll j=find(val);
        if(j!=-1)  return m*i+j+cnt;
        ans=ans*t%C;
    }
    return -1;
}
void pre() {for(int i=0;i<=mod;i++)hash[i].f=0,hash[i].num=hash[i].v=-1;}
int main()
{
    while(~scanf("%d%d%d",&C,&A,&B))
    {
        if(!(A+B+C))  break;
        if(C==1)  {puts("0"); continue;}
        pre();  A%=C;  B%=C;
        ll ans=Shank();
        if(ans==-1)  puts("no solution");
        else printf("%lld\n",ans);
    }
    return 0;
}


Frida提取Cocos游戏XXTEA密钥的实战方法论 XXTEA是一种轻量级分组加密算法,广泛用于移动端游戏通信保护;其128位密钥的安全性直接决定网络协议逆向成败。在Cocos引擎生态中,密钥常以静态常量、JNI动态传递或Native运行时派生三种形态存在,导致传统静态分析失效。Frida凭借跨Java/Native注入能力与内存实时观测优势,成为捕获密钥‘出生瞬间’的关键工具——尤其适用于hook xxtea_encrypt函数入口、监控JNI参数传递、设置内存断点追踪派生过程等场景。本文聚焦Cocos2d-x与Cocos Creator项目,覆盖从密钥识 阅读详情

相关推荐

temu登录接口逆向分析(含Py纯算)

【代码】temu登录接口逆向分析(含Py纯算)

数据精灵喵 1962

[BZOJ2629]binomial (高精度+Lucas定理+离散对数+FFT)

题意:对于给定的n和p,求对于所有的0 注:p虽然要输入,但是题目标注了所以测试点的p是固定的。 首先需要用正确的姿势理解lucas定理,比如求C(n,r)%p,就是将n和r分别转换为p进制,然后依次算组合数乘起来。n是一个高精度数,求C(n,r)的过程中,n不断模p得到的数(即n的p进制表示)是固定的。 就是长这样:n0!/((n0-k0)!*k0!) * n1!/((n1-k1)!*k1

AZUI _ oi memories 944

怎么定位K8s容器中运行的JAVA程序OOM异常(一)

一.前置环境 1. 运行在k8s集群上的Pod服务(Java程序) 2. MAT分析工具 二.利用Jmap工具导出Heap Dump 1.执行命令进入pod容器 kubectl exec -itn {namespace} {pod}} sh 2.利用jmap生成java程序的Dump文件 jps | grep {jar} ./jmap -dump:live,format=b,file=haep.hprof 8 3.利用k8s命令导出Dump文件到本地 kubectl cp -n

计算科学 3014

BZOJ 3239 Discrete Logging BSGS

题目大意:对于,给定a,b,p,求x,其中p为质数。裸Baby-step-Giant-step这里写的还不错#include <cstdio> #include <algorithm> #include <cmath> #include <map> using namespace std; typedef long long LL; LL f_pow(LL x,LL y,LL MOD) {

YihAN_Z 414

一种车内UWB圆极化天线的理论推导及具体实现

本文详细描述了一款工作于UWB channel 9也即中心频率为7987.2MHz,带宽为499.2MHz的圆极化天线。首先是理论推导圆极化天线的物理尺寸参数,分析物理尺寸参数对天线性能指标的影响。然后分析圆极化天线在汽车驾驶室这种狭窄空间应用中带来的优势,也即可以最大化的极化损失多径,提高主径接收信号的信噪比。

weixin_44555637的博客 2975

告别RXTX:SpringBoot集成jSerialComm实现更现代的串口通信(附完整代码对比)

本文详细介绍了如何从传统的RXTX库迁移到jSerialComm,实现SpringBoot项目中更现代的串口通信。通过对比两种技术的依赖配置、API设计和跨平台支持,展示了jSerialComm在简化部署、提升性能和增强稳定性方面的优势,并提供了完整的代码示例和实战经验。

weixin_42522964的博客 293

【BZOJ】【P3239】【Discrete Logging】【题解】【BSGS】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3239 裸题 Code: #include using namespace std; typedef long long LL; LL p,a,b; LL pw(LL x,LL k,LL p){ LL ans=1; for(;k;k>>=1){ if(k&1)ans=(ans*x

退役狗的专栏 1万+

FaceFusion模型下载与NSFW解除:从环境配置到可回滚补丁指南

开源人脸替换(deepfake)技术近年发展迅速,以FaceFusion为代表的方案依赖ONNX模型推理链路完成人脸检测、识别与融合。这类项目的模型权重文件动辄数GB,自动下载脚本在弱网环境下极易中断,而内置的内容审核(NSFW)逻辑又常常误伤普通素材,成为开发者跑通流程的两大障碍。从工程实践角度看,模型部署的本质是环境适配与依赖管理,难点在于版本匹配、文件完整性和运行时后端选择;内容审核的解除则需理解检测阈值与调用链位置,采用可回滚补丁而非直接改源码。在短视频特效、虚拟形象生成等应用场景中,稳定性是规模化

weixin_29044713的博客 470

[BZOJ3239][poj2417]Discrete Logging(BSGS算法)

如是良人长相绝,尤恐梦中思上邪。

zyf2000 1523

超融合架构实战:如何用3节点搭建企业级分布式存储系统?

本文详细介绍了如何利用3节点搭建企业级分布式存储系统的超融合架构实战指南。从硬件选型、网络配置到存储策略调优,提供了全面的实操建议和性能优化技巧,帮助企业实现高效、弹性的IT基础设施。特别适合需要简化运维、提升存储性能的中型企业参考。

weixin_29200485的博客 335

本地 AI 自由!OpenClaw+Ollama 双系统部署教程(Windows/Linux),零成本离线跑大模型

本文详细介绍了如何在Windows和Linux双系统中部署OpenClaw AI助手,并通过Ollama对接本地大模型实现完全离线使用。教程包含环境准备、OpenClaw安装配置、Ollama本地模型部署、系统对接等完整流程,特别强调隐私安全和零Token消耗的优势。针对不同操作系统提供具体命令,并给出常见问题解决方案,即使是新手也能快速搭建专属本地AI助手。最终实现的方案无需联网、无使用成本,且能保障数据隐私安全。

2501_93651177的博客 7247

baby_step giant_step hdu 2815 mod tree pku 3243 Clever Y

原创帖!转载请注明作者 AekdyCoin ! 【普通Baby Step Giant Step】【问题模型】求解A^x = B (mod C) 中 0 <= x < C 的解,C 为素数【思路】我们可以做一个等价x = i * m + j ( 0 <= i < m, 0 <=j < m) m = Ceil ( sqrt( C) )而这么分解的目的无非是为了转...

weixin_33735077的博客 296

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

BSGS 扩展大步小步法解决离散对数问题 (BZOJ 3239: Discrete Logging// 2480: Spoj3105 Mod)

我先转为敬

Ark 403

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

【BZOJ 3239】 Discrete Logging

BSGS(大步小步)算法~

Regina8023 1233

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【BZOJ3239】Discrete Logging BSGS

【BZOJ3239】Discrete Logging Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 2 <= N < P, compute the discrete logarithm of N, base B, mo...

aodanchui1057的博客 187

BZOJ3239Discrete Logging

3239: Discrete Logging Time Limit: 1 Sec Memory Limit: 128 MB Submit: 372 Solved: 238 Description Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 2 <= N < P, compute th

DCrusher's blog 811

【bzoj3239】Discrete Logging BSGS

DescriptionGiven a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 2 <= N < P, compute the discrete logarithm of N, base B, modulo P. That is, find an integer L such thatBL == N (mod

DQS的树洞 737

bzoj3239 Discrete Logging

Description Given a prime P, 2 &lt;= P &lt; 231, an integer B, 2 &lt;= B &lt; P, and an integer N, 2 &lt;= N &lt; P, compute the discrete logarithm of N, base B, modulo P. That is, find an integer ...

olahiuj的博客 322

Bzoj3239:Discrete Logging:BSGS模板题

题目链接3239:Discrete Logging 裸BSGS,终于会写了QAQ #include #include #include #include #include #include #define LL long long using namespace std; const int maxn=1500010; const int mod=99997; LL p,b,c,ans; bo

蜜の夜明け 601

【bzoj3239】 Discrete Logging

BSGS模板题

zhaoyh2000的博客 355

BZOJ3239Discrete Logging——BSGS

题目大意:给出$P,B,N$,求最小的正整数$L$,使$B^L\equiv N(mod\ P)$。 $BSGS$模板题。 #include<set> #include<map> #include<queue> #include<stack> #include<cmath> #include<cstdio> ...

weixin_30498807的博客 67

BZOJ 3239 Discrete Logging Baby-Step-Giant-Step

题目大意:给定P,B,N,求最小的L使B^L≡N (mod P) (P是质数) 裸的BSGS。。。 练练手吧- - #include #include #include #include #include #define M 100100 #define INF 0x3f3f3f3f using namespace std; typedef pair abcd; long long

世界 1506

bzoj 3239: Discrete Logging BSGS

题意给出b,p,n,求一个l,使得bl=n(modp)b^l=n(\mod p)分析离散对数模板题,当复习一波。 思路是把l分块,然后扔进map里。代码#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> #include<map> #d

beginend 386
上一篇: 【bzoj2480】Mod 离散对数
下一篇: 【bzoj2242】计算器 离散对数
chty_syq
博客等级 码龄10年 33粉丝 172原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值