Codeforces 201E Thoroughly Bureaucratic Organization (智商题。。)
来源:互联网 发布:python 写入txt文件 编辑:程序博客网 时间:2024/04/29 23:47
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> #include <set> #include <ctime> #include <cstdlib> using namespace std; #define inf 0x3f3f3f3f#define N 10000020#define M 1000020#define LL long long#define mod 1000000007#define ls (i << 1)#define rs (ls | 1)#define md (ll + rr >> 1)#define lson ll, md, ls#define rson md + 1, rr, rs#define B 350int n, m;int qpow(int x, int k) {int ret = 1;while(k) {if(k & 1) ret = 1LL * ret * x % mod;k >>= 1;x = 1LL * x * x % mod;}return ret;}bool check(int k) {if(n == 1) return 1;LL sum = 1, t = 1LL * k * m;double c = 1;LL s = 1;for(int i = 1; i <= k; ++i) {LL x = t / i, y = mod;if(x == 0) return 0;c = c * (k - i + 1) / i;s = s * (k - i + 1) % mod * qpow(i, mod - 2) % mod;if(c < mod) y = s;x = min(x, y);sum += x;if(sum >= n) return 1;t -= x * i;}return 0;}int main() {int cas;scanf("%d", &cas);while(cas--) {scanf("%d%d", &n, &m);int l = 0, r = n;while(l < r) {int mid = (l + r) / 2;if(check(mid)) r = mid;else l = mid + 1;}printf("%d\n", l);}return 0;}
0 0
- Codeforces 201E Thoroughly Bureaucratic Organization (智商题。。)
- CodeForces 351A 智商题
- codeforces 351A A. Jeff and Rounding(智商题+枚举)
- Organization
- Organization
- ORGANIZATION
- codeforces 191 E 数据结构题
- Codeforces 366E 模拟题
- codeForces 509E 想法题
- 笔试题??智商题??
- 计算机智商题
- 趣味智商题
- Ball--智商题
- Tea--智商题
- noip2016 蚯蚓 智商题
- 智商测试题
- UVALive 7147 -智商题
- 智商
- sqlite创建表成功,insert不报错,但没有数据插入
- 17.Studio中导入HttpClient的jar包
- c++中子类调父类构造函数的规则
- Using existing Bootstrap themes in Liferay (Part I).
- 开发DataSnap服务器
- Codeforces 201E Thoroughly Bureaucratic Organization (智商题。。)
- c++第二次实验——学生成绩
- quartus modelsim-altera, Can't launch the Modelsim-Altera Software
- sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.9.2: not found
- Android下数据库的操作应用(三)
- 查临时表空间对应的数据文件
- QQ分享
- Android 中的 Service 全面总结
- iOS开发 - AFNetworking 的使用(第三方库)