#include <bits/stdc++.h> #define gcd __gcd #define bitcount __builtin_popcountll #define rep(i,j,n) for(i=j;i<n;i++) #define tr(it,c) for(auto it=(c).begin();it!=(c).end();it++) #define pb push_back #define mp make_pair #define hell 1000000007 #define uset unordered_set #define umap unordered_map #define ft first #define sc second using namespace std; typedef pair<int,int> pi; typedef long long ll; template <class T> T& get(T &n) { cin>>n; return n; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N,i; cin>>N; vector<bool> visited(N,0); vector<int> a(N); vector<double> p(N); rep(i,0,N){ get(a[i])--; get(p[i])/=100; } double ans=0; for(int i=0;i<N;i++){ if(!visited[i]){ // cerr<<"Begin "<<endl; int j=i; uset<int> now; while(!now.count(j) && !visited[j]){ // cerr<<"\t"<<j<<endl; now.insert(j); j=a[j]; } now.insert(j); // int k; // rep(k,0,N){ // cerr<<visited[k]<<' '; // } // cerr<<endl; if(visited[j]){ // assert(!now.count(j)); tr(it,now) visited[*it]=1; continue; } tr(it,now) visited[*it]=1; int start=j; // cerr<<"Start="<<start<<endl; double t=1; do{ t*=p[j]; j=a[j]; }while(start!=j); ans+=t; // cerr<<"Pro:"<<t<<endl; } } static char s[100]; sprintf(s,"%.2lf",ans); cout<<s<<endl; return 0; }