###### tags: `Zerojudge` 【題解】apcs f579: 1.購物車 === Posted on 2022/4/21 | By : Victoria1103 【題目敘述】https://zerojudge.tw/ShowProblem?problemid=f579 ```cpp= #include <iostream> #define IOS ios::sync_with_stdio(0),cin.tie(0) using namespace std ; int main (){ int a , b ; int n ; int ans = 0 ; //輸出值 IOS; cin >> a >> b ; cin >> n ; for (int i = 0 ; i < n ; i++ ){ int inp ; int a_in = 0 ; //總共被拿了幾次 int b_in = 0 ; cin >> inp ; //輸入第一種商品 while (inp!=0){ //取到沒商品為止 if (inp == a){ a_in ++ ; } else if (inp == -a){ a_in -- ; } if(inp == b){ b_in ++ ; } else if (inp == -b){ b_in -- ; } cin >> inp ; //輸入下一個商品 } if(a_in >= 1 && b_in >= 1){ ans++ ; } } cout << ans << "\n" ; 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