# UVa 1185 ### 題目連結:[UVa1185](http://domen111.github.io/UVa-Easy-Viewer/?1185) <font color="darkblue" size="3">無中譯</font> ### 題述: 給你一個 n , 求 n! 有幾位數。 --- 輸入的第一列有一個整數代表以下有多少組測試資料。 再來會有一個整數 , 代表 n ( *10^0^* ≤ *n* ≤ ***10^7^*** )。 --- 對每個測資 , 請輸出 n! 的位數。 ### c++ code: ```cpp= #include<bits/stdc++.h> #include<cmath> using namespace std; int main () { //------------------------------------------------ #ifdef local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //------------------------------------------------ int n ; int a ; double sum ; cin >> n ; while ( n-- ) { sum = 0 ; cin >> a ; for ( int i = 1 ; i <= a ; i++ ) { sum += log10(i) ; } cout << (int)sum + 1 << endl ; } } ``` :::success **``sample input``** 2 10 20 ::: :::success **``sample output``** 7 19 ::: #### [返回首頁](https://hackmd.io/@fkleofk/APCS#1185) ###### tags: `APCS選修` `C++` `UVa`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up