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

首頁 > 學院 > 開發設計 > 正文

求n(10000以內)的階乘

2019-11-10 23:34:46
字體:
來源:轉載
供稿:網友

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

#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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵石县| 吴川市| 稷山县| 江都市| 永城市| 大港区| 香港 | 榆树市| 宝兴县| 嘉兴市| 乌兰察布市| 武冈市| 璧山县| 沛县| 云梦县| 安义县| 五大连池市| 平顶山市| 四会市| 安图县| 卓资县| 桦甸市| 天等县| 黄骅市| 茂名市| 宁武县| 永胜县| 宜兴市| 五原县| 荥阳市| 铜梁县| 清原| 榆社县| 格尔木市| 博湖县| 巴中市| 香港| 白山市| 剑川县| 光泽县| 韶关市|