2019 Multi-University Training Contest 8
2019 Multi-University Training Contest 8
Acesrc and Good Numbers
题意求<=x最大的n,满足1−n中的所有数的数位中数d出现了n次
从网上找了个板子,是求1−n中d出现的次数,这里叫它count(n,d)复杂度logn
因为我们要找<=x最大的n
我们先算一下count(x,d)
如果count(x,d)==x
自然x就是我们想要的结果
如果count(x,d)<x
我们就可以直接把x赋值成count(x,d)
因为他们之间的数肯定是大于我们想要的结果的
如果count(x,d)>x
我们假设x是一个m位数,并且他的所有位数都是d
在这样的情况下我们只需要重新让x=x−(count(x,d)−x)/m即可
因为在最坏的情况下所有的位数都是d
我们要想让count(x,d)和x相等,至少要它减去(count(x,d)−x)/m个数
Calabash and Landlord
Quailty and CCPC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <bits/stdc++.h> using namespace std; const double eps=1e-6; int n,d; struct node { char name[15]; int x,y; bool operator <( const node &b) const { if (x==b.x) { return y<b.y; } else { return x>b.x; } } }a[101000]; int main() { int _; scanf( "%d" ,&_); while (_--) { scanf( "%d%d" ,&n,&d); for ( int i=1; i<=n; i++) { scanf( "%s %d %d" ,a[i].name,&a[i].x,&a[i].y); } sort(a+1,a+n+1); double kk=n*d*0.1; int k=kk; if (fabs(fabs(k-kk)-0.5)<eps) { k++; printf( "%s\n" ,a[k].name); } else { printf( "Quailty is very great\n" ); } } } |
Roundgod and Milk Tea
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <bits/stdc++.h> using namespace std; const int maxn=1000100; typedef long long ll; ll ans1,ans2,suma,sumb; int a[maxn],b[maxn],n,tmp; int main() { int _; scanf( "%d" ,&_); while (_--) { suma=sumb=0; ans2=0; scanf( "%d" ,&n); for ( int i=1; i<=n; i++) { scanf( "%d%d" ,&a[i],&b[i]); suma+=a[i]; sumb+=b[i]; } ans1=min(suma,sumb); for ( int i=1; i<=n; i++) { tmp=min(a[i]*1ll,sumb-b[i]); ans2+=tmp; } printf( "%lld\n" ,min(ans1,ans2)); } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步