1 solutions
-
0
C :
#include<stdio.h> int main(){ int i,n,c=0; scanf("%d",&n); for(i = 5;i <= n;i++){ int w = i / 10000; int q = i / 1000 % 10; int b = i / 100 % 10; int s = i / 10 % 10; int g = i % 10; if((w == 5 || q == 5 || b == 5 || s == 5 || g == 5) && i % 5 == 0){ c++; } } printf("%d",c); return 0; }
C++ :
#include<iostream> #include<math.h> using namespace std; int main(){ int n,i,a,b,c,d,e,f = 0; cin>>n; i = 1; while(i <= n){ a = i / 10000; b = i / 1000 % 10; c = i / 100 % 10; d = i / 10 % 10; e = i % 10; if((i % 5 == 0) && (a == 5 || b == 5 || c == 5 || d == 5 || e == 5) ){ f++; } i++; } cout<<f<<endl; return 0; }
- 1
Information
- ID
- 10892
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By