# 我就邊 https://neoj.sprout.tw/problem/3291/ ### 題目敘述 邊邊是邊緣人,只好玩一個人就能玩的的遊戲(´;ω;\`) 遊戲一開始,玩家在起點0的位置,透過抽牌決定能走幾次,以及每次能往右走幾步 遊戲流程如下: ``` 先抽出1張牌,決定終點N 再抽出1張牌,決定能走的次數M 最後抽出M張牌,依序為每次走的步數 ``` 懇請大家同情邊邊,幫邊邊計算,能不能剛好走到終點 ### 輸入說明 第一行有一個正整數T,代表邊邊玩了T次遊戲,有T組測資。每組測資的第一行有一個正整數N,N≤1000,第二行有一個正整數M,M≤1000,第三行有M個正整數a1,a2,...aM, ai≤1000 ### 輸出說明 如果剛好抵達終點,輸出"WIN",否則輸出"LOSE" (不含雙引號,要換行) ### 範例輸入 ``` 3 7 3 1 2 4 10 2 1 4 9 4 1 5 2 1 ``` ### 範例輸出 ``` WIN LOSE WIN ``` # Code ```cpp #include <iostream> #include <math.h> using namespace std; int main(){ int T , N , u , M , x , K=0 , m; cin>>T; int t=1; while (t<=T){ cin>>N; cin>>M; int m=1,u=0; while (m<=M){ cin>>x; u=u+x; m++; } if (u!=N){ cout<<"LOSE"<<"\n"; } else { cout<<"WIN"<<"\n"; } t++; } } ```
×
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