一开始做这题时大脑短路……连用浮点数来表示都没想到,所以我的做法是取1~n的对数,然后加起来,再减去一个整数使那个浮点在1~2的范围内,pow10以后取个位,答案就出来了。后来想想,用浮点这题有可能也做得出来,不大可能出现误差的~ P.S. 今天刚刚发现浮点没法做。long double的范围只到10的4000多次,而100000!可以到10的450000多次!所以用浮点不现实的了~~#include<iostream>#include<cmath>using namespace std;int main(){ long double e; long data,c,d,f; cin>>data; while(data-- > 0) { cin>>c; if(c<4) { for(d=2,f=1;d<=c;d++) f*=d; cout<<f<<endl; continue; } for(d=2,e=0.0;d<=c;d++) e += log10l((long double)d); while(e>=2.0) e -= 1.0; e = powl(10.0,e); c = e; while(e-c>0.99) c+=1; cout<<c%10<<endl; } return 0;} 转载于:https://www.cnblogs.com/FancyMouse/articles/219754.html 来源:https://blog.csdn.net/weixin_30907523/article/details/99267350 标签 浮点