fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long double dis(long double x, long double y, long double z, long double a, long double b, long double c){
  5. long double res1 = (x - a) * (x - a);
  6. long double res2 = (y - b) * (y - b);
  7. long double res3 = (z - c) * (z - c);
  8. long double res = sqrt(res1 + res2 + res3);
  9. return res;
  10. }
  11. struct st{
  12. long double fi, se, thi;
  13. } f[25];
  14. int sx[25] = {0};
  15. int main() {
  16. long double n, a, b, c, x, y, z,ak,bk,ck,res;
  17. int v = 1,t;
  18. while(cin >> n) {
  19. if(n == 0) return 0;
  20. cin >> a >> b >> c;
  21. for(int i = 0; i < n; ++i) {
  22. cin >> x >> y >> z;
  23. f[i].fi = x;
  24. f[i].se = y;
  25. f[i].thi = z;
  26. }
  27. memset(sx,0,sizeof(sx));
  28. t = 5000000/n;
  29. while(t--){
  30. ak = (long double)rand() / RAND_MAX * a;
  31. bk = (long double)rand() / RAND_MAX * b;
  32. ck = (long double)rand() / RAND_MAX * c;
  33. // cout << ak <<" "<<bk<<" "<<ck<<" ";
  34. long double minn = 1000000;
  35. int j = 0;
  36. for(int i = 0; i < n; ++i) {
  37. // cout << f[i].fi <<" "<<f[i].se<<" "<<f[i].thi <<endl;
  38. res = dis(f[i].fi, f[i].se, f[i].thi, ak, bk, ck);
  39. if(res < minn) {
  40. minn = res;
  41. j = i;
  42. }
  43. }
  44. // cout << j << endl;
  45. sx[j]++;
  46. }
  47. cout <<"Case "<<v<<": ";
  48. ++v;
  49. for(int i = 0; i < n; ++i) {
  50. cout<<setprecision(3)<< sx[i] / (5000000/n)<< " ";
  51. }
  52. cout << endl;
  53. }
  54. }
  55. //2 3 3 3
  56. //1 1 1
  57. //2 2 2
  58.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty