oj整除和商的问题1104
来源:互联网 发布:淘宝店卖什么比较火 编辑:程序博客网 时间:2024/05/16 11:45
#include<iostream>
#include<cstring>
using namespace std;
int main( )
{
int n,a,m,x;
int res[10010];
while(cin>>n>>a)
{
int flag=0;
int i, j;
memset(res, 0, sizeof(res));
res[0] = 1;
res[1] = 1;
for (i = 2; i <= n; i++)
{
for (j = 1; j <= res[0]; j++)
res[j] = res[j] * i;
for (j = 1; j <= res[0]; j++)
{
if (res[j] >= 10)
{
res[j+1] += res[j] / 10;
res[j] %= 10;
if (j == res[0])
res[0]++;
}
}
}
m=res[0];
int p=0;
int q;
do{
for(i=m;i>=1;--i)
{ q=p;
p=(10*p+res[i])%a;
res[i]=(10*q+res[i])/a;
}
if(p==0) flag=flag+1;
}while(p==0);
cout<<flag<<endl;
}
return 0;
}
#include<cstring>
using namespace std;
int main( )
{
int n,a,m,x;
int res[10010];
while(cin>>n>>a)
{
int flag=0;
int i, j;
memset(res, 0, sizeof(res));
res[0] = 1;
res[1] = 1;
for (i = 2; i <= n; i++)
{
for (j = 1; j <= res[0]; j++)
res[j] = res[j] * i;
for (j = 1; j <= res[0]; j++)
{
if (res[j] >= 10)
{
res[j+1] += res[j] / 10;
res[j] %= 10;
if (j == res[0])
res[0]++;
}
}
}
m=res[0];
int p=0;
int q;
do{
for(i=m;i>=1;--i)
{ q=p;
p=(10*p+res[i])%a;
res[i]=(10*q+res[i])/a;
}
if(p==0) flag=flag+1;
}while(p==0);
cout<<flag<<endl;
}
return 0;
}
- oj整除和商的问题1104
- 九度OJ 1104:整除问题 (整除、因式分解)
- 九度OJ 1104 整除问题
- 九度OJ 1104 整除问题
- 九度oj 题目1104:整除问题
- 九度OJ 1104 整除问题
- 九度 oj 题目1104:整除问题
- 九度OJ-1104:整除问题
- 九度OJ-1104-整除问题
- 各位和整除数的问题
- 各位和整除数的问题
- 刷清橙OJ--A1067.Fibonacci数列整除问题
- hdu 2099 整除的尾数(整除问题)
- 题目1104:整除问题
- 题目1104:整除问题
- 题目1104:整除问题
- 交大1104,整除问题
- 题目1104:整除问题
- JSP乱码问题
- 第十周-求1000以内所有偶数的和(for语句)。
- linux下Vim设置显示行数 tab空格数
- tcp客户/服务器回射程序之五-----用shutdown函数解决在批量方式下所引起的问题
- Android eclipse中程序调试
- oj整除和商的问题1104
- 《More Effective C++》条款26:限制某个Class所能产生的对象数量
- 农业银行校园招聘笔试精华资料共享
- wireshark抓回环数据
- SQLServer资源及性能监控
- 常见多线程与并发服务器设计方案举例
- step-by-step多文件WEB批量上传(swfupload)的完美解决方案
- 记录类型
- 如何把一个网站做起来