HDU 1212 大整数的取模运算
2024-09-02 20:14:44
因为这里是MOD最大为100000
所以我将字符串看作5个一组,并记录后面跟了多少个100000
每次取5个数根据其数据进行取模更新
注意过程中 100000*100000会超int
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define ll long long
int b;
char s[]; int main()
{
// freopen("a.in" , "r" , stdin);
while(~scanf("%s%d" , s , &b))
{
int len = strlen(s);
int p = len- , t = ; //t表示后面要乘几次100000
int cur = ;
while(p >= ){
ll num = , mul = ;
for(int i = ; i<&&p>= ; i++){
num += mul * (s[p] - '');
mul *= ;
p--;
}
// cout<<"num: "<<num<<endl;
num = num % b;
for(int i = ; i<=t ; i++){
num *= ;
num %= b;
}
num += cur;
num %= b;
cur = num;
t++;
}
printf("%d\n" , cur);
}
return ;
}
最新文章
- qt5.5程序打包发布以及依赖【转】
- iOS10 拍照崩溃问题
- 在VC++6.0开发中实现全屏显示
- 错误解决:SharePoint Designer 2010编辑后,出现数据源控件未能执行插入命令,data source control failed to execute the insert command
- Activiti 学习笔记记录(二)
- SQL Server配置管理器”远程过程调用失败“的问题解决
- Spring整合Hibernate。。。。
- wcf通过webHttpBinding方式发布rest web服务
- 如何利用花生壳和VisualSVN Server建立远程代码仓库
- python 传入参数返回的时候好像有些时候会出现莫名其妙的循环
- POJ 1166 The Clocks
- 转:如何在 LoadRunner 脚本中做关联 (Correlation)
- C# WebSocket Fleck 调用非托管C++ DLL 实现通信(使用stringbuilder接收)
- Jenkins持续集成介绍及插件安装版本更新演示(一)--技术流ken
- c# 数据存储过程
- Deep Reinforcement Learning for Visual Object Tracking in Videos 论文笔记
- kendo-ui表单验证
- 如何去除WIN7任务栏项目上右键菜单中的最近访问一栏
- Intro to Python for Data Science Learning 7 - 2D NumPy Arrays
- 导出 java.io.IOException: 权限不够
热门文章
- codehunter 「Adera 6」杯省选模拟赛 网络升级 【树形dp】
- bzoj1015星球大战(并查集+离线)
- typescript进阶篇之高级类型与条件类型(Readonly, Partial, Pick, Record)
- less新手入门(四)—— Mixin Guards
- [读书笔记2]《C语言嵌入式系统编程修炼》
- HDU 4691 后缀数组+RMQ
- EditText(2)自定义回车键的行为
- 【[转】MySql模糊查询
- [转]ASP.NET MVC中实现多个按钮提交的几种方法
- visual studio 2015安装