T1

             

思路:

  输入数据,sort一下,
  如果a[i]>sum+1(前缀和)
  那么sum+1就一定不会被拼出来,
  然后输出即可.

上代码:

#include <iostream>
#include <cstdio>
#define LL long long
using namespace std; const int Maxn = ;
int n;
LL sum,a[Maxn]; int main() {
freopen("lost.in","r",stdin);
freopen("lost.out","w",stdout);
scanf("%d",&n);
for(int i=; i<=n; ++i) scanf("%lld",&a[i]);
sort(a+,a++n);
for(int i=; i<=n; ++i) {
if(sum+<a[i]) {
printf("%lld",sum+);
return ;
}
else sum+=a[i];
}
printf("%lld",sum+);
return ;
}

T1


T2

思路:

  1.i<=sqrt(n)
  2.i>sqrt(n)
    30%
      暴力枚举
    100%
      1.n/i-n/(i+1)<=1 <---> n<=i*(i+1)
      //单调递减--->解不等式O(1)进行求解
      2.二分答案

上代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
using namespace std; typedef long long LL;
LL n;
bool check(LL x) { // n <= x*(x+1)
if(x*.*(x+)>1e18) return true;
if(n <= x *(x+)) return true;
return false;
}
int main() {
freopen("div.in","r",stdin);
freopen("div.out","w",stdout);
scanf("%lld",&n);
if(n==) {
puts("");
} else if(n==) {
puts("");
} else {
LL L = ,R=n-;
while(R-L>) {
LL mid = (L+R)/;
if(check(mid)) R=mid;
else L=mid;
}
// assert(check(R));
printf("%lld\n",L+(n/R));
}
return ;
}

100


T3

思路:

  1.60% 2^n 进行枚举
    其实来个普通的dfs就行233
  2.100%
    qwq我我我...暂时不会

上代码:

#include<cstdio>
#include<iostream>
using namespace std; const int M = ;
int n,m,vi[M];
double ans[M],pi[M],arcpi[M]; void dfs(int now,int Count,int Money,double k) {
if(now>n) {
if(Money>=m) ans[Count]+=k;
return;
}
dfs(now+,Count,Money+vi[now],k*pi[now]);
dfs(now+,Count+,Money,k*arcpi[now]);
} int main() {
freopen("diamond.in","r",stdin);
freopen("diamond.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=,tmp; i<=n; i++) {
scanf("%d%d",&vi[i],&tmp);
pi[i]=1.0*tmp/,arcpi[i]=1.0-pi[i];
}
dfs(,,,);
for(int i=; i<=n; i++) printf("%.3lf\n",ans[i]);
return ;
}

最新文章

  1. spin.js
  2. FastJson转换自定义枚举类
  3. CentOS设置默认启动命令行(不启动图形界面)
  4. codeforces A. Flipping Game 解题报告
  5. CentOS 6 RPM安裝python 2.7
  6. Linux:crontab命令学习
  7. HDOJ(HDU) 2503 a/b + c/d(最大公约数问题)
  8. POJ 2002 点hash
  9. 微信小程序(兼容性问题)
  10. rest_framework之认证源码剖析
  11. 痞子衡嵌入式:第一本Git命令教程(7.1)- 清理之缓存(stash)
  12. Android JNI 学习(四):接口方法表 &amp; Base Api &amp; Exception Api
  13. gd_t , bd_t 结构分析
  14. Java高级开发必会的50个性能优化细节
  15. AngularJS封装UEditor
  16. Android 关于在ScrollView中加上一个ListView,ListView内容显示不完全(总是显示第一项)的问题的两种简单的解决方案
  17. PyCharm License Activation激活码失效问题的解决方法
  18. HDU4513:完美队形II(Manacher)
  19. mac下面安装redis
  20. Android与Unity交互研究

热门文章

  1. 从入门到自闭之Python解释器安装
  2. hdu 1869 枚举+Dijstra
  3. django+uwsgi+nginx: websock 报502/400
  4. js将阿拉伯数字转换成汉字大写
  5. js摄像头
  6. net core体系-Xamarin-2概要(lignshi)
  7. 关键字:for_each
  8. 一个下午整理的Web前端常见的英文缩写
  9. DX使用随记--ImageComboBoxEdit
  10. jmeter连接mysql数据库进行单条语句查询