[Codeforces Round #160 (Div. 2)]A. Roma and Lucky Numbers
地址:http://codeforces.com/contest/262/problem/A
最开始没考虑到不多于k包括0的情况,所以对第一组样例奇怪了一会
题很简单,一个一个来判断,通过取余来判断,通过除法来移位
1 #include <stdio.h> 2 int n,k; 3 int main() 4 { 5 int i=0,con=0,num=0,ans=0; 6 scanf("%d %d",&n,&k); 7 for(i=0;i<n;i++) 8 { 9 con=0; 10 scanf("%d",&num); 11 while(num!=0) 12 { 13 if(num%10==4 || num%10==7) con++; 14 num=num/10; 15 if(con>k) break; 16 } 17 if(con<=k) ans++; 18 } 19 printf("%d\n",ans); 20 return 0; 21 }

浙公网安备 33010602011771号