HDU 3105 Fred's Lotto Tickets [Ad Hoc]

来源:互联网 发布:手机微信崩溃数据丢失 编辑:程序博客网 时间:2024/06/09 13:49

Description

n行数,一行6个,问这6*n个数里面是不是1~49都出现过

Algorithm

开个布尔数组记录下,然后每次出现就s++,最后看s是不是49

Hint

是Yes 不是 YES,搞得WA了一次

Code

#include <iostream>using namespace std;int n;void solve(){  bool b[50] = {false};  int s = 0;  for (int i = 0; i < n; i++)    for (int j = 0; j < 6; j++)    {      int x;      cin >> x;      if (!b[x])      {        b[x] = true;        s++;      }    }  if (s == 49) cout << "Yes" << endl; else cout << "No" << endl;}int main(){  for (;;)  {    cin >> n;    if (n == 0) break;    solve();  }}
0 0
原创粉丝点击