阶乘因式分解(1)
来源:互联网 发布:程序员考试考什么 编辑:程序博客网 时间:2024/06/11 05:15
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a;
scanf("%d",&a);
int b,flag;
flag=0;
scanf("%d",&b);
while(1)
{
flag+=a/b;
a=a/b;
if(a==0)
break;
}
printf("%d\n",flag);
}
}
先输入a=100,b=5;a!=1*2*3*.....99*100;a/b是5,10,15...95,100中b的个数,存在flag中,再一次a/b是因为25,50,75,100,
中有两个b;如果还有就需要再次a/b;最后输出flag的值;
#include <stdio.h>
#include <string.h>#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a;
scanf("%d",&a);
int b,flag;
flag=0;
scanf("%d",&b);
while(1)
{
flag+=a/b;
a=a/b;
if(a==0)
break;
}
printf("%d\n",flag);
}
}
阅读全文
0 0
- 阶乘因式分解(1)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(二)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(二)
- 阶乘因式分解(二)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(一)
- 阶乘因式分解(二)
- 阶乘因式分解(二)
- JAVA设计模式之【代理模式】一(静态代理)
- Linux硬链接与软链接
- HDU-6000-Wash
- 内置的常用层:LayerColor、LayerGradient
- 前端优化策略列举(一)
- 阶乘因式分解(1)
- 华山论剑:微服务框架-SpringCloud、Dubbo or Istio
- ERROR: Couldn't open giveio.sys Failed to open Dongle JTAG(parallel port)
- RSA加密算法原理
- 网络请求工具类
- HALCON基于形状的模板匹配
- MIPI DSI 协议介绍
- Anaconda安装TensorFlow及安装Spyder编译器
- Python排序算法总结