t-shirt
根据题意写代码即可, 在区间内的所有排名得到衣服的概率和 乘 发生在区间内的概率, 然后用 1 除一下就可以了

#define _rep(i,a,b) for(int i = (a); i <= (b); i++) void task1() { int t; cin >> t; while(t--) { int l,r, z = 0; cin >> l >> r; double p1 = 1.0/(r-l+1), ans = 0.0; //cout << " p1 = " << p1 << " "; _rep(i,l,r) { ans += (1.0/(i)); } cout << fixed << setprecision(10) << 1.0/(ans*p1) << " "; } return; }
game
。。。一直wa,没注意细节 当有两个人都大于1金币时, 肯定结束不了 我知道这个但是写错了。。。。
其实结论就是 第一个拥有金币的人操作完以后就赢了, 比如说只有他一个人拥有金币 namo 他肯定赢了 或者说还有一个人有且仅有一个金币 namo他把这个金币拿了 他也赢了, 其他情况都是游戏结束不了的

#define _for(i,a,b) for(int i = (a); i < (b); i++) void task2() { int t; cin >> t; while(t--) { int n; cin >> n; vector<int> a(n); int cnt1 = 0, cnt2 = 0, cnt3 = 0, f = 0; _for(i,0,n) { cin >> a[i]; if(!f and a[i] >= 1) f = i+1; if(a[i] >= 1) cnt1++; else cnt3++; } if(cnt1 == 1) {cout << f << " "; continue;} if(cnt1 == 2) { for(int i = n-1; i >= 0; i--) if(a[i] >= 1) { if(a[i] == 1) cout << f << " "; else cout << "namo "; break; } } else cout << "namo "; } return; }