【CSU-2185】解题报告(水题)

原始题目

2185: a simple problem

  • Time Limit: 1 Sec
  • Memory Limit: 128 Mb
  • Submitted: 78
  • Solved: 46

Description

My girlfriend loves 7 very much, she thinks it is lucky! If an integer contains one or more 7, she will think it is lucky too! ### Input There are multiple test files and each contains one case. The number of cases is at most 100. For each test case, there is only one line with an integer \(X ( 1 ≤ X ≤ {10}^{9} )\).

Output

For each test case, if \(X\) contains one or more 7, output “Lucky”(without quotation marks), otherwise output “Unlucky”(without quotation marks).

Sample Input

17171

Sample Output

Lucky

Hint

Source

题目大意

输入一串字符,字符中有7则输出“Lucky”,否则输出“Unlucky”

解题思路

逐位判断

解题代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<set>
#include<queue>
#include<map>
#include <algorithm>
#include <stack>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define np next_permutation
#define cl(x,a) memeset(x,a,sizeof(x))
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
using namespace std;
const int maxn=1e5+5;
const int maxm=1e5+5;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<string,string> pss;

int n,t;

int main(){
while(~scanf("%d",&n)){
int flag=0;
while(n){
if(n%10==7){
flag=1;
break;
}
n/=10;

}
if(flag) printf("Lucky\n");
else printf("Unlucky\n");
}
}

收获与反思