1 solutions
-
0
C :
#include<stdio.h> int main() { int i,a,b,c,n,d,s=0,e; scanf("%d",&n); for(i=10000;i<=n;i++) { a=i/10000; b=i/1000%10; c=i/100%10; d=i/10%10; e=i%10; if(a%2==0&&b%2==0&&c%2==0&&d%2==0&&e%2==0) s++; } printf("%d",s); return 0; }
C++ :
#include <iostream> using namespace std; int main(){ int n,i,r = 0,g,s,b,q,w; cin>>n; for(i=10000;i<=n;i++){ w = i / 10000; q = i /1000 % 10; b = i / 100 % 10; s = i / 10 % 10; g = i % 10; if(w%2==0&&q%2==0&&b%2==0&&s%2==0&&g%2==0){ // cout<<i<<endl; r = r + 1; } } cout<<r; }
Java :
import java.util.Scanner; public class Main{ public static void main(String[] agrs){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int num = 0; for(int i = 10000;i <= n;i++){ if((i / 10000 % 2 == 0) && (i / 1000 % 10 % 2 == 0) && (i / 100 % 10 % 2 == 0) && (i / 10 % 10 % 2 == 0) && (i % 10 % 2 == 0)){ num++; } } System.out.println(num); } }
Python :
n = int(input()) c = 0 for i in range(10000, n + 1): w = i // 10000 % 10 q = i // 1000 % 10 b = i // 100 % 10 s = i // 10 % 10 g = i // 1 % 10 if w % 2 == 0 and q % 2 == 0 and b % 2 == 0 and s % 2 == 0 and g % 2 == 0: c += 1 print(c)
- 1
Information
- ID
- 10517
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By