# 0-5 進階運算 講義不是我寫的,網址在此 https://emanlaicepsa.github.io/2020/10/21/0-index/ 我只是將自己寫的練習題程式碼記錄下來。 最後更新日期:2024年10月5日 ## [TOJ: 99 / d - Determinant](https://toj.tfcis.org/oj/pro/99/) ### Python 程式碼 執行時間最久約為 30 ms,使用記憶體最多約為 4140 kB,通過測試。 ```python= m0, m1 = map(float, input().split()) m2, m3 = map(float, input().split()) det = abs(m0*m3 - m1*m2) print("1" if det > 1E-7 else "0") ``` ### C++ 程式碼 測試時,第1、2、7、8、9筆測資不過。 ```cpp= #include<iostream> using namespace std; int main() { double m0, m1; cin >> m0 >> m1; double m2, m3; cin >> m2 >> m3; double det = m0*m3 - m1*m2; double eps = 1E-9; if (det < eps && det > -eps) cout << 0 << "\n"; else cout << 1 << "\n"; return 0; } ``` ## [100 / e - English Alphabet](https://toj.tfcis.org/oj/pro/100/) ### Python 程式碼 執行時間最久約為 149 ms,使用記憶體最多約為 4120 kB,通過測試。 ```python= c = input() print(chr(ord(c)-1)) ``` ### C++ 程式碼 執行時間最久約為 2 ms,使用記憶體最多約為 364 kB,通過測試。 ```cpp= #include<iostream> using namespace std; int main() { char c; cin >> c; cout << char(c - 1) << endl; return 0; } ``` ## [101 / e' - English Alphabet Prime](https://toj.tfcis.org/oj/pro/101/) ### Python 程式碼 執行時間最久約為 39 ms,使用記憶體最多約為 4228 kB,通過測試。 ```python= n = int(input()) print(chr(n - 1 + ord('A'))) ``` ### C++ 程式碼 執行時間最久約為 2 ms,使用記憶體最多約為 560 kB,通過測試。 ```cpp= #include<iostream> using namespace std; int main() { int n; cin >> n; cout << char(n + 'A' - 1) << endl; return 0; } ``` ------ ###### tags:`演算法`、`APCS`、`Python`、`C++`
×
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