HDU_开灯问题

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 int a[1002]={1};
 5 
 6 int main()
 7 {
 8     int n,i,j,k,t;
 9 
10     scanf("%d%d",&n,&k);
11    
12    for(i=1;i<=n;i++)
13    {
14        a[i]=1;
15    }
16     for(j=2;j<=k;j++)
17     {
18         for(t=1;t<=n;t++)
19         {
20             if(t%j==0)
21             {
22                 a[t]=-a[t];
23             }
24         }
25     }
26     for(i=1;i<=n;i++)
27     {
28         if(a[i]==1)
29         {
30             printf("%d ",i);
31         }
32     }
33     printf("
");
34 
35 
36     return 0;
37 }
原文地址:https://www.cnblogs.com/41412179guo/p/4486528.html