hdu 4485 B-Casting
来源:互联网 发布:银龙裁决淘宝 编辑:程序博客网 时间:2024/05/22 03:18
求b进制数模b-1的值。。。
b进制(xn.。。。x3x2x1x0)的值可以写成 xn*b^n+x(n-1)*b^(n-1).....
(xn*b^n)%(b-1)=(xn*((b-1)+1)^n)%(b-1)=xn*(c(n,0)*(b-1)^0+c(n,1)*(b-1)^1+....c(n,n)*(b-1)^n)%(b-1)=xn%(b-1)
故等同于 (x1+x2+x3+...xn)%(b-1)
注意数的长度为10000000.。。
#include<iostream>#include<string.h>using namespace std;char s[10000005];int main(){int n,l,num,b,t,i;cin>>t;while(t--){cin>>num>>b>>s;l=strlen(s);n=0;for(i=0;i<l;i++)n=(n+s[i]-'0')%(b-1);cout<<num<<" "<<n%(b-1)<<endl;}return 0;}
- hdu 4485 B-Casting
- HDU 4485 B-Casting
- hdu 4485 B-Casting (数学)
- 简单数学题-hdu-4485-B-Casting
- HDU 4485 B-Casting (基础题)
- UVALive 6173|HDU 4485|B-Casting|水体
- Uva 6173 B-Casting
- hdu4485 B-Casting(mod运算)
- Casting
- up casting down casting
- Type Casting
- Casting Strings
- Type Casting
- Type Casting
- Type Casting
- Casting malloc
- Type Casting
- Casting operator
- 如何从iphone中获取无线网络参数,包括运营商网络和WiFi?
- 正确区分v o i d 与v o i d *
- ASP.NET(WCF)操作Word的权限配置
- android分辨率详解
- JavaScript程序执行顺序
- hdu 4485 B-Casting
- Ioctl ASYNC_CONFIG error, errno = 1
- Wifi connect under command
- 为什么我们觉得微软不是很‘酷’
- jQuery Mobile页面跳转后未加载外部JS
- POJ-1068-Parencodings
- 解开VC++调用.Net DLL的神秘面纱
- Windows/Linux/Mac上清除DNS缓存的命令
- DIV的边距属性在Chrome和IE中的区别