程序博客网 > 人工智能医疗 图片
来源:互联网 发布:人工智能医疗 图片 编辑:程序博客网 时间:2024/05/16 01:07
/*An irrational decimal fraction is created by concatenating the positive integers:0.12345678910(1)112131415161718192021...It can be seen that the 12th digit of the fractional part is 1.If dn represents the nth digit of the fractional part, find the value of the following expression.d1 * d10 * d100 * d1000 * d10000 * d100000 * d1000000*/#include <iostream>#include <vector>#include <stack>#include <Windows.h>using namespace std;typedef unsigned long DWORD;const unsigned digit = 1000000;vector<int> d;stack <int> num;intmain(){DWORD sTime = GetTickCount();bool finsh = false;for (int n=0;finsh==false;n++){ int tmp = n; while (tmp!=0) { int sn = tmp % 10; num.push(sn); tmp /= 10; } while (!num.empty()) { int dn = num.top(); num.pop(); d.push_back(dn); if (d.size()==digit+1) { finsh = true; break; } }}int result = 1;for (int i=1; i<=digit; i*=10){//cout << "d[" <<i<<"] = " << d[i-1] << '/n';result *= d[i-1];}cout << result << '/n';DWORD eTime = GetTickCount();cout << "the running time = " << eTime - sTime << " ms." << '/n';return 0;}