fork download
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.  
  5. int n, m, t,i;
  6. int a[10000];
  7. scanf ("%d %d", &n, &m);
  8. memset(a, 0, 10000*(sizeof(int)));
  9. for (i = 0 ; i < m ; ++i){
  10. scanf ("%d", &t);
  11. a[t-1] = a[t-1] + 1;
  12. }
  13. for (i = 0 ; i < n; ++i){
  14. printf("%.2f%\n", (float)(a[i]*100)/m);
  15. }
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 2296KB
stdin
3 6
1
2
3
2
1
1
stdout
50.00%
33.33%
16.67%