#include<bits/stdc++.h> #define int long long #define endl '\n' typedeflonglong ll; usingnamespace std; string m = "0123456789ABCDEF0"; inthextodec(string &s, ll i, ll j){ int res = 0; char c = s[i]; for (ll t = i; t <= j; t++, c = s[t]) { if ('0' <= c && c <= '9') { res = res * 16 + c - '0'; } else { res = res * 16 + c - 'A' + 10; } } return res; } string dectohex(int d){ string res = ""; while (d != 0) { res = m[d % 16] + res; d /= 16; } while (res.size() != 2) { res = "0" + res; } return res; } voidsolve(){ string rgb1; string rgb2 = "#"; cin >> rgb1; int r = hextodec(rgb1, 1, 2); int g = hextodec(rgb1, 3, 4); int b = hextodec(rgb1, 5, 6); r = 255 - r; g = 255 - g; b = 255 - b; rgb2 += dectohex(r) + dectohex(g) + dectohex(b); cout << rgb2 << endl; } signedmain(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) solve(); return0; }
#include<bits/stdc++.h> #define int long long #define endl '\n' typedeflongdouble ld; constdouble PI = 3.141592653589793; usingnamespace std;
ld f(ld w, ld r){ return2 * r * r * asinl(w / (2 * r)) + w * sqrtl(r * r - w * w / 4); }
ld df(ld w, ld r){ return r * w / sqrtl(r * r - w * w / 4) - w / sqrtl(1 - w * w / (4 * r * r)) + 4 * r * asinl(w / (2 * r)); }
voidsolve(){ ld l, w, s; cin >> l >> w >> s; ld r = w / 2; if (f(w, r) > s || s > PI * l * l / 4) { printf("-1\n"); return; } r = w / 2 + 1e-3; // 导数在r=w/2处间断,为了可以计算,我们加上一个微扰 ld dr = (f(w, r) - s) / df(w, r); while (fabs(f(w, r) - s) > 1e-6) { // 跳出条件直接就是计算面积与实际面积差的绝对值 <= 1e06 r -= dr; dr = (f(w, r) - s) / df(w, r); } if (w <= 2 * r && 2 * r <= l) // 判断r的范围是否符合条件 printf("%.15Lf\n", r); else printf("-1\n"); } signedmain(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) solve(); return0; }
K Yet Another Card Game I
题目描述
<% note info no-icon %> Please note: Statement of this problem
is in English. <% endnote %>
Rheanna and her friend Yasmine are about to play a game with a deck
of cards, where the face values
form a permutation of length .
They split the deck into two equal piles and each takes one. In the game
consisting of rounds, they select
and play a card from their respective hands, comparing face values
during each round. The player with the higher value scores a point, and
the loser scores nothing. After
rounds, the player with the higher total score wins. Rheanna
plays first in each round, but she felt that this is unfair to
her, so she turned to you before game started, expecting you can tell
her if there's a sure-fire way to win. In other words, you need to
determine who would win if both players play optimally.
A permutation of length is an
array consisting of distinct
integers from to in arbitrary order. For example, is a permutation, but is not a permutation (2 appears
twice in the array), and is
also not a permutation ( but
there is in the array).
输入描述
Each test contains multiple test cases. Let be the number of test cases, the input
file consists of lines.
The first line contains the number of test cases . The description of the test cases
follows.
The first line of each test case contains one integer , as described in the problem
statement.
The next line contains integers
-- the face
values of cards held by Rheanna.
The last line also contains
integers -- the
face values of cards held by Yasmine.
输出描述
You should output lines.
For each test case, output Rheanna if Rheanna
wins, or Yasmine if Yasmine wins. It can be
easily proven that the game will not end in a draw, namely there will
always be a clear winner and loser.