敲七

1135: 敲七

Time Limit: 1 Sec  Memory Limit: 128 MB

Description

输出7和7的倍数,还有包含7的数字例如(17,27,37...70,71,72,73...)

Input

一个整数N。(N不大于30000)

Output

统计出不大于N的与7有关的数字的个数。如20以内与7有关的数为7、14、17共3个。

Sample Input

20

Sample Output

3

HINT

Source

吉首大学软件服务外包学院

 1 #include <stdio.h>
 2 #include <string.h>
 3 int main ()
 4 {
 5     int a;
 6     while(scanf("%d",&a)!=EOF)
 7     {
 8         int ans=0;
 9         for(int i=7; i<=a; i++)
10         {
11             if(i==7||i%7==0)
12             {
13                 ans++;
14                 continue;
15             }
16             if(i>10)
17             {
18                 for(int j=10,k=1;j<=10000; k*=10,j*=10)
19                 {
20                     if((i%j)/k==7)
21                     {
22                         ans++;
23                         break;
24                     }
25                 }
26             }
27 
28         }printf("%d\n",ans);
29 
30     }
31     return 0;
32 }

 

posted on 2015-08-19 19:46  甜蜜蜜吖甜蜜蜜  阅读(516)  评论(0编辑  收藏  举报

导航