UVa 10220 【大整数】
2024-08-31 14:34:55
可采用uva 623这道题求N!,再最后稍微改一下就好。
参考代码:
}
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn = ;
int f[maxn]; int main()
{
int n;
while (cin >> n)
{
memset(f, , sizeof(f));
int len = ;
f[] = ;
for (int i = ; i <= n; i++)
{
int c = ;
for (int j = ; j < len; j++)
{
int t = f[j] * i + c;
f[j] = t % ;
c = t / ;
}
if (c) f[len++] = c;
}
int ans = ;
for (int i = len - ; i >= ; i--) {
while (f[i])
{
int t = f[i] % ;
ans += t;
f[i] /= ;
}
}
cout << ans << endl;
}
return ;
}
最新文章
- virtualbox之usb设备的分配
- grid style
- HTML-正则表达式
- MyEclipse从数据库反向生成实体类之Hibernate方式 反向工程
- Tea---hdu5881(规律)
- read,for,case,while,if简单例子
- operator重载的使用
- 2015年阿里巴巴蚂蚁金服校招JAVA研发工程师内推电话面试
- 【巧妙预处理系列+离散化处理】【uva1382】Distant Galaxy
- 【原创】leetCodeOj ---Remove Duplicates from Sorted List II 解题报告
- ural1855 Trade Guilds of Erathia
- static 及 extern
- 用IO流中的File类来创建文件及目录
- 0_Simple__fp16ScalarProduct
- 将 MVVM 演化为 MVVMM
- ES6躬行记(2)——扩展运算符和剩余参数
- 使用proxy来简单的实现一个观察者
- Leetcode 326.3的幂 By Python
- 归并排序merge_sort
- php file_get_contents fopen 连接远程文件