1212 big number.cpp
来自「威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。」· C++ 代码 · 共 36 行
CPP
36 行
/*
1212 Big Number
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
/*
(a * b) % c = ((a % c) * (b % c)) % c
(a + b) % c = ((a % c) + (b % c)) % c
*/
#include <iostream>
#include <string>
using namespace std;
const int bMax=100000;
const int aMax=1000;
int main()
{
int b,len,i,temp;
char a[aMax];
while(cin>>a>>b)
{
len=strlen(a);
for(i=0,temp=0;i<len;i++)
{
temp=( (10*temp)%b + (a[i]-'0') ) % b ;
}
cout<<temp<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?