Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
41980818 Practice:
Salma_Essa
839C - 36 C++14 (GCC 6-32) Wrong answer on test 4 15 ms 98264 KB 2018-08-23 04:23:03 2018-08-23 04:23:03
→ Source
#include <bits/stdc++.h>
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define pb push_back
#define ll long long
#define ull unsiigned long long
#define sz size()

using namespace std;
int const maxN =100000000;
double eps =1e-9;
long long  mod=1000000007;
vector<pair<ll,ll> > u ;
long long power(long long  a, long long  b)
{
    if (b == 0) return 1;
    if (b == 1) return a%mod;
    if (b % 2 == 0) return power((a*a)%mod, b / 2)%mod;
    else return (a * power((a * a)%mod, (b - 1) / 2))%mod;
}
vector<int>pr;
bool comp[maxN+5];
void seive()
{
 comp[1]=1; comp[0]=1;
 for(int i=4 ; i<=maxN ; i+=2)
    comp[i]=1;
 for(ll i=3 ; i*i<=maxN ;i+=2)
 {

  if (comp[i%maxN]==0)
  { for(ll j=i*i ; j<=maxN ; j+=i )
      comp[j]=1;

  }


 }
 for(ll i=0  ; i<=maxN ; i++)
{if (!comp[i]) {pr.pb(i); if (i-2>0&&!comp[i-2]) { u.pb(make_pair(i-2,i));} }

}
}




struct MyLessString
{
    bool operator () (const string& lhs, const string& rhs) const
    {
        return lhs.size() == rhs.size() ?
                    lhs < rhs : lhs.size() < rhs.size();
    }
};
int n;
bool see[10000];
map<int,vector<int> > v;
double sum=0;
set<int>s;
set<int>::iterator it;
void dfs(int node, int l,double z)
{

  see[node]=1;
  if (v[node].sz==1&&node!=0) {sum+=(l*(1/z)); return ; }
  for(int i=0 ; i<v[node].sz; ++i)
  {   int k=v[node][i];
     if (!see[k]) dfs(k,l+1,v[node].sz);

  }

}

int main() {
  //freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout
ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
cin>>n; int x,y;

for(int i=0 ; i<n-1; ++i)
{
   cin>>x>>y;
   x--; y--;
   v[x].pb(y);  v[y].pb(x);
}
dfs(0,0,1);
cout<<fixed<<setprecision(6)<<sum;

    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details