hdu 1930 And Now, a Remainder from Our Sponsor 扩展欧几里得 解一元线性同余方程组

『杭电1930』And Now, a Remainder from Our Sponsor #include<iostream> #include<cstdio> #include<list> #include<algorithm> #include<cstring> #include<string> #include<queue> #include<stack> #include<map> #include<vector> #include<cmath> #i... 阅读详情
/**
* url : http://acm.hdu.edu.cn/showproblem.php?pid=1930
* stratege : 解一元线性同余方程组, 扩展欧几里得
* Author: johnsondu
* Status: johnsondu 0MS 284K 2207B C++ 2012-08-19 13:13:15 
* Trick: There will be no blank in the end of the text 
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstring>
#include <map>
#include <string>
#include <iomanip>
using namespace std;

const int N = 2005 ;
int key[N], num, n ;
int str[N] ;
int res[N] ;
int r[N] ; 

void input ()
{
    int i ;
    scanf  ("%d", &n) ;
	memset (res, 0, sizeof (res)) ;
	memset (str, 0, sizeof (str)) ;
	memset (r, 0, sizeof (r)) ;
	memset (key, 0, sizeof (key)) ;
	num = 0 ;
    for (i = 0; i < 4; i ++)  // key
        scanf ("%d", &key[i]) ;
    for (i = 0; i < n; i ++)  // the set of remainder
        scanf ("%d", &str[i]) ;
	
	
}

void exGcd (int a, int b, int &d, int &x, int &y)  // Extended_Euclid
{
    if (b == 0)
    {
        d = a ;
        x = 1 ;
        y = 0 ;
        return ;
    }
    exGcd (b, a%b, d, x, y) ;
    int tmp = x ;
    x = y ;
    y = tmp - (a/b)*y ;
}

void getNum ()
{
    int i, j ;
    int a, b, c, d, x, y ;
    for (i = 0; i < n; i ++)
    {
        r[3] = str[i] % 100 ;        //transform the set of remainder into the 
        r[2] = (str[i]%10000)/100 ;  //single remainder of the key
        r[1] = (str[i]%1000000)/ 10000 ;
        r[0] = str[i]/1000000; 

		int ta = key[0] ;
		int tr = r[0] ;
									//mission: x = r1 (mod a1), x = r2 (mod a2), ..., find x ;
        for (j = 1; j < 4; j ++)    //a1, a2, ... are key[i], r1, r2, ... are r[i] 
        {							//find the str[i]'s value 
            a = ta, b = key[j] ;
			c = r[j] - tr ;
            exGcd (a, b, d, x, y) ;
			
			int t = b/d ;
			x = (x*(c/d)%t + t) % t ;
			tr = ta*x + tr ;
			ta = ta * (key[j]/d) ;
        }
        res[i] = tr ;
    }
}

void output ()
{
	int i ;
	int a, b, c ;
	char destr [10005] ;
	int len = 0 ;
	for (i = 0; i < n; i ++)
	{
		a = res[i] / 10000 ;
		b = (res[i] % 10000) / 100 ;
		c = res[i] % 100 ;
		
		if (a != 27)
			destr[len++] = 'A' + a - 1 ;
		else destr[len++] = ' ' ;
		if (b != 27)
			destr[len++] = 'A' + b - 1 ;
		else destr[len ++] = ' ' ;
		if (c != 27)
			destr[len++] = 'A' + c - 1 ;
		else destr[len ++] = ' ' ;
	}
	while (destr[len-1] == ' ')  //ignore the blank in the end of text.
	{
		len -- ;
	}
	for (i = 0; i < len; i ++)
		printf ("%c", destr[i]) ;
	printf ("\n") ;
}

int main ()
{
    int tcase ;
    scanf ("%d", &tcase)  ;
    while (tcase --)
    {
        input () ;
        getNum () ;
		output () ;
    }
    return 0 ;
}

详细对比模型训练和模型精调 当我们进行模型精调(Fine-Tuning)和模型训练时,我们需要考虑到不同的步骤和目标。 阅读详情

相关推荐

解决vscode无法运行npm命令的问题(cmd可行)

Powershell以及vscode中npm命令使用不了

无痕坚守本心的博客 2748

hdu1930 And Now, a Remainder from Our Sponsor-----中国剩余定理

And Now, a Remainder from Our Sponsor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 380    Accepted Submission(s): 153 Problem Descrip

Shirley 1692

Multisim仿真入门:单相半波可控整流电路从搭建到波形分析(附避坑指南)

本文为电力电子技术初学者提供了一份详细的Multisim仿真指南,手把手教你从零搭建单相半波可控整流电路。通过对比纯电阻、阻感负载及加入续流二极管后的波形变化,直观理解晶闸管触发、电感续流等核心原理,并附有实用的参数设置与常见问题避坑指南,帮助你将抽象理论转化为可视化的工程实践。

weixin_29208077的博客 343

HDU1930 And Now, a Remainder from Our Sponsor 解线性同余方程的应用

这道题过的人很少,原因肯定是因为英语,这题目意思i 我看了好久,英语太差了,题目的意思是: 先给你四个数,然后给你n个数,把n个数中的每一个数给拆成四个数,怎么拆按题目要求,拆出来的这四个数作为同余方程   x≡ai(mod ri) 中的 ri,最先给出的四个作为key的四个数,作为方程中的 ai,然后求出x, 总的意思就是先给你四个作为key的四个数, 给你n个数,把n个数中的每一个

shaonianguai 1307

告别迷茫!用ETAS RTA-OS配置你的第一个AUTOSAR OS任务(含VRTA虚拟ECU实战)

本文详细介绍了如何使用ETAS RTA-OS工具链在VRTA虚拟ECU上配置和运行第一个AUTOSAR OS任务。通过从XML配置到任务调度的全流程实战,帮助开发者快速掌握嵌入式操作系统开发的核心步骤,特别适合刚接触AUTOSAR的开发者快速上手。

weixin_42533622的博客 418

OpenHarmony自定义Launcher

OpenHarmony源码版本:4.0release开发板:DAYU / rk3568DevEco Studio版本:4.0.0.600切换分支为OpenHarmony-4.0-Release,并下载源码。

Abner_Crazy的博客 1628

HDU - 1930 And Now, a Remainder from Our Sponsor (中国剩余定理)

IBM has decided that all messages sent to and from teams competing in the ACM programming contest should be encoded. They have decided that instead of sending the letters of a message, they will trans...

smilng的博客 213

解决TexStudio编写LaTeX论文引用文献问题:正文引用处出现[?],参考文献也不显现

当我们利用LaTeX编写论文时,可能会出现引用参考文献时正文引用处出现?号,肯能的原因及解决方案如下: 问题一 忘记在\end{document}前面放\bibliographystyle{样式}和\bibliography{参考文献bib文件名}: \bibliographystyle{plain} \bibliography{sample} 其中, LaTeX 标准选项及其样式共有以下8种: plain,按字母的顺序排列,比较次序为作者、年度和标题. unsrt,样式同plain,只是按照引用的先后

左手の明天的博客 9527

hdu 1930 中国剩余定理(互质模板题)

And Now, a Remainder from Our Sponsor Time Limit : 5000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 23Accepted Submission(s) : 13 Problem Description IB...

weixin_30883777的博客 197

【Flutter 问题系列第 16 篇】如何防止软键盘弹出后顶掉内容

Flutter 如何防止软键盘弹出后顶掉内容

“Allen Su”的博客 3314

9.1 机器人动力学建模

目录9.1 机器人动力学建模一、机器人动力学的基本概念1. 什么是机器人动力学?2. 动力学方程二、机器人动力学建模方法1. 拉格朗日方法2. 牛顿-欧拉方法三、Simulink 中的机器人动力学建模1. 使用 Simscape Multibody 建模示例:构建一个两连杆机械臂的动力学模型。步骤:2. 使用 Robotics System Toolbox 建模示例:构建一个六自由度工业机器人的动力学模型。步骤:四、示例:两连杆机械臂的动力学建模目标:步骤:五、结果分析1. 动态响应2. 参数敏感性六、总结

xiaoheshang_123的博客 625

And Now, a Remainder from Our Sponsor (中国剩余定理互质情况)

And Now, a Remainder from Our Sponsor IBM has decided that all messages sent to and from teams competing in the ACM programming contest should be encoded. They have decided that instead of sending t...

codeswarrior的博客 286

YOLO26涨点改进 | 全网独家复现、小目标检测改进篇 | TGRS 2025 | YOLO26引入MFAE-YOLO中的GFFP、FCPS 和 C3k2-FPEU创新点,涨点起飞,直接发论文

🔥本文给大家介绍在YOLO26中引入MFAE-YOLO中的 GFFP(全局特征融合处理)、FCPS(特征通道像素注意力) 和 C3k2-FPEU(特征池提取单元) 二次创新改进模块,能显著提升对小目标的检测性能。GFFP通过多尺度特征融合增强全局上下文感知能力,有效提升小目标在复杂背景下的可辨性;FCPS融合通道、像素和空间注意力机制,增强了模型对关键细节和小区域特征的关注,提升检测精度;C2F-FPEU利用多种池化方式挖掘细节特征,优化浅层特征表示能力。三者协同提升了YOLO26在小目标检测中的鲁棒性。

Ai缝合怪、助力小伙伴高效发论文 303

杭电DP题目(dynamic programming)

<br />这里集中了很多的动态规划题目,我也从这里开始突破啦<br />----------------------------------------------------------------------------------------------<br /> <br />   记我今天开始,正式向ACM营地出发,努力搞好自己的优快云博客<br /> <br />                                turn potential to reality !<br />

小do在努力 2569

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

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

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

HDU 1312 Red and Black

看了好多天的DFS,基本上的程序都是要借助解题报告才可以实现 但是这一题,确实依照自己的思路,完全靠自己写出来的,或许比较简单吧,所以特此发表下文章,犒劳一下自己,再接再厉 http://acm.hdu.edu.cn/showproblem.php?pid=1312 Red

小do在努力 2547

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

杭电1051 经典贪心

这题真是抓狂,我已经提交了8次,还是没过,我都找不到任何错误数据了粘贴下别人的代码提交下,就是果断过。。。求大牛指点……/* title:Wooden Sticks url: http://acm.hdu.edu.cn/showproblem.php?pid=1051 我的做题思想: 主要是通过下表法,首先对数组的length按从小到大排序 然后,通过第一元素开始,进行比较,如果后面的任一 一组数据与当前数据进行比较,length和weight都比目前 length 和 weight 都小

小do在努力 2126

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Uva 10104 Euclid Problem |x|+|y|最小解 扩展欧几里得

/* * url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1045 * stratege: 求ax+by=gcd(a,b), |x|+|y|的和的x,y,的解, 扩展欧几里得,分四种情况考虑 * status:10541367 1010

小do在努力 2113

LightOj 1111 - Best Picnic Ever

/** * Author: johnsondu * time: 2013-4-11 * problem: LightOj 1111 - Best Picnic Ever * url: http://lightoj.com/volume_showproblem.php?problem=1111 * stratege: DFS, count the person who can r

小do在努力 1881

POJ 3641 HDU 1905 Pseudoprime numbers 素数 模取幂

/* --------------------------------------------------- status : a312745658 3641 Accepted 328K 16MS C++ 1732B 2012-05-18 21:36:37 stratege : 快速模取幂,素数筛选, 判断一个大数是否为素数 URL: http:

小do在努力 1814

HDU 1211 RSA 逆元 快速模取幂

/** * url: http://acm.hdu.edu.cn/showproblem.php?pid=1211 RSA * Author: Johnsondu * Time: 2012-7-28 18:00 around * Stratege: 逆元(扩展欧几里德) , 快速模取幂 * Status: 6364213 2012-07-28 18:12:54 Accepte

小do在努力 1731

HDU 1010 Tempter of the Bone

关于DFS如何学好,先援引大牛的几点建议: (1)先理解搜索的原理,区别好bfs和dfs的优先搜索方向以及应用,例如bfs一般用来求最优解如最短路径. (2)掌握好所用的数据结构,特别是队列. (3)牢记dfs和bfs的常用模式,它是基本固定的,考试时信手拈来! (4)注

小do在努力 1682

uva 10830 A New Function

/* * Author: johnsondu * time: 2013-4-25 * problem: uva 10830 - A New Function * url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1771 * so

小do在努力 1641

Uva 11395 - Sigma Function 规律 对数

/* * 规律:通过打表后发现,在n的范围内,只有2^x 以及 平方数 和 平方数的2倍符合要求。 * 即:2^1, 2^2,... 1*1, 2*2,... 2*1*1, 2*2*2, 2*3*3... 等等,故只要去重就可以了 * url: http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_p

小do在努力 1635

HDU 1559 最大子矩阵

/** * Author : johnsondu * time : 2013-4-7 * Type: DP, I want to really understand it * problem: 最大子矩阵 * url: http://acm.hdu.edu.cn/showproblem.php?pid=1559 */ #include #include #include

小do在努力 1629

LightOj 1054 Efficient Pseudo Code

/* * Author: johnsondu * time: 2013-4-25 * meanning: 求出约数和n ^ m的约数和,快速模取幂,扩展欧几里德,素数筛选 * problem: LightOj 1054 * url: http://lightoj.com/volume_showproblem.php?problem=1054 * */ #include #i

小do在努力 1622

NYOJ38 布线问题 prim算法 kruscal算法

/* problem : NYOJ38 布线问题 stratege: kruscal algorithm URL :http://acm.nyist.net/JudgeOnline/problem.php?pid=38 status :166386 1006100213 布线问题 Accepted 76 4216 C/C++ 05-13 21:57:42 */

小do在努力 1500
上一篇: HDU 1588 Gauss Fibonacci 矩阵
下一篇: Sicily 1721 Gray code[Special judge]
小do在努力
博客等级 码龄16年 58粉丝 161原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值