Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fst first
- #define snd second
- #define all(x) (x).begin(), (x).end()
- #define rall(x) (x).rbegin(), (x).rend()
- #define clr(a, v) memset( a , v , sizeof(a) )
- #define pb push_back
- #define mp make_pair
- #define sz size()
- #define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
- #define FOR( i , n ) FORN( i , 0 , n )
- #define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
- #define trace(x) cout << #x << ": " << x << endl;
- #define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl;
- #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
- #define read ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- using namespace std;
- typedef long long int64;
- typedef vector <int> vi;
- typedef pair <int,int> ii;
- typedef vector <string> vs;
- typedef vector <ii> vii;
- int W[105];
- int H[105];
- int L[105];
- double R[105];
- int main(){
- int T;
- cin>>T;
- FORN(caso, 1, T+1){
- int N;
- double P;
- printf("Case #%d: ", caso);
- cin>>N>>P;
- double aux = 0.0;
- FOR(i,N) {
- cin>>W[i]>>H[i];
- L[i] = min(W[i], H[i]) * 2;
- R[i] = sqrt( (W[i]*W[i]) + (H[i]*H[i]) ) * 2.0;
- P -= 2*(W[i] + H[i]);
- aux += 2*(W[i] + H[i]);
- }
- int cnt = P / L[0];
- double ans = aux + min((double)P, R[0] * (double)cnt);
- printf("%.08f\n", ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement