# (YKL20(UVA10050)) Hartals : YKL20_UVA10050_Hartals.cpp ## 注意 vector 是從0 開始 所以說 要給他 n+1 把d[0] 直接不用就可以了 ## code ```cpp! #include <iostream> #include <vector> using namespace std; int main() { int t; cin >> t; // 迴圈 t 次測資 for (int i = 0; i < t; i++) { int n, p; cin >> n >> p; // 紀錄哪天有罷工 vector<int> d(n + 1, 0); int count = 0; for (int j = 0; j < p; j++) { int m; cin >> m; for (int k = m; k <= n; k += m) { if (k % 7 != 6 && k % 7 != 0) { if (d[k] == 0) { count++; d[k] = 1; } } } } cout << count << endl; } return 0; } ```
×
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