2 solutions
-
0
#include<bits/stdc++.h> using namespace std; bool check(int x) //判断是否含有7 { while(x) { int ge=x%10; if(ge==7) return true; x/=10; } return false; } bool check2(int x) //判断是否是回文 { int t=x; int res=0; while(t) { int ge=t%10; res=res*10+ge; t/=10; } if(x==res) return true; return false; } int main() { int n,m; cin>>n>>m; int cnt=0; for(int i=n;i<=m;i++) { if(check(i)&&check2(i)) //同时含有7和回文 { cnt++; } } cout<<cnt; return 0; }
-
-1
#include<bits/stdc++.h> using namespace std; bool check(int x) //判断是否含有7 { while(x) { int ge=x%10; if(ge==7) return true; x/=10; } return false; } bool check2(int x) //判断是否是回文 { int t=x; int res=0; while(t) { int ge=t%10; res=res*10+ge; t/=10; } if(x==res) return true; return false; } int main() { int n,m; cin>>n>>m; int cnt=0; for(int i=n;i<=m;i++) { if(check(i)&&check2(i)) //同时含有7和回文 { cnt++; } } cout<<cnt; return 0; }
- 1
Information
- ID
- 1271
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 42
- Accepted
- 12
- Uploaded By