Coding Test/Baekjoon
[25304 c++] 백준 영수증
안경말이
2022. 10. 26. 06:03
cin은 공백(space, enter..) 기준으로 끊어 입력을 받습니다.
따라서, 2000 5를 각각 a,b에 입력받고 싶을 때 cin>>a>>b로 사용하면 되며, 공백까지 입력받고 싶을 때는 getline을 사용하면 됩니다.
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x,n,a,b;
int rest=0;
cin>>x>>n;
for(int i=0; i<n; i++){
cin>>a>>b;
rest += a*b;
}
if(rest == x)cout<<"Yes";
else cout<<"No";
}