×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
分類題庫
解題動態
排行榜
討論區
競賽區
登入
註冊
發表新討論
#55407: c++ org BS
61247091s@gapps.ntnu.edu.tw
(wei)
學校:
不指定學校
編號:
244449
×
傳送站內訊息
傳給:
主題:
內容:
來源:
[123.192.182.169]
註冊時間:
2023-09-07 14:39:22
最後登入時間:
2025-11-28 22:26:54
f679.
公會成員
--
教學題
| From: [123.192.179.85] | 發表日期: 2026-07-05 20:25
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,q;
cin>>n>>q;
vector <int> v(n);
for(int i=0;i<n;i++)cin>>v[i];
while(q--){
int t;
cin>>t;
bool tmp=false;
int low=0,high=n-1;
while(low<=high){
int mid=low+(high-low)/2;
if(t==v[mid]){
cout<<"Yes\n";tmp=true;break;
}
else if(t<v[mid])high=mid-1;
else if(t>v[mid])low=mid+1;
}
if(!tmp)cout<<"No\n";
}
return 0;
}