国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

求n(10000以內(nèi))的階乘

2019-11-11 00:35:47
字體:
供稿:網(wǎng)友

題目地址 http://noi.openjudge.cn/ch0106/14/ 把結(jié)果分開存儲,存到數(shù)組或容器中

#include<iostream>#include<string>#include<time.h>#include<iomanip>using namespace std;#include<vector>void cheng(vector<unsigned long long int> &result, int t){ int temp=0; for (auto &x : result) { unsigned long long int q = (x*t + temp) /1000000000000000; x = (x*t+temp) % 1000000000000000; temp = q; } if (temp != 0) result.push_back(temp);}int main(){ std::ios::sync_with_stdio(false);// int a = clock(); vector<unsigned long long int> result; result.push_back(1); result.clear(); result.push_back(1); int N;cin >> N; for (int t = 2;t <= N;t++) cheng(result, t); cout << result.back(); for (auto it = result.rbegin() + 1;it != result.rend();it++) cout << setw(15) << setfill('0') << *it; cout << endl;// int b = clock();// cout << b - a << endl;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 兰考县| 平山县| 保亭| 连州市| 湟源县| 驻马店市| 沙坪坝区| 雷山县| 张家川| 南郑县| 耿马| 孝昌县| 安图县| 巴南区| 滁州市| 凤庆县| 疏附县| 巩留县| 怀来县| 兴海县| 潜江市| 元谋县| 吴忠市| 博乐市| 盐池县| 萨迦县| 宜章县| 泸溪县| 建德市| 崇明县| 临城县| 宜宾市| 封丘县| 余姚市| 江津市| 高陵县| 贵州省| 永州市| 桐城市| 平遥县| 安岳县|