POJ Who Gets the Most Candies? 线段树 第 5天
来源:互联网 发布:图标设计图案软件 编辑:程序博客网 时间:2024/05/21 05:55
擦,看了一上午,他妈的,终于试出来错误。。。。
50W个点,我开了 100W + 8 的数组,原以为够了。。。。。。他妈的就错在这了。。。
真的想骂两句。。。。。
#include<iostream>#include<cstdio>#define lson id << 1#define rson id << 1 | 1using namespace std;struct Linetree{ int len,left,right; int mid() { return (left + right) / 2; }}node[1100008]; void _btree(int id,int l,int r){ node[id].left = l;node[id].right = r; node[id].len = r - l + 1; if(l == r) return ; int mid = node[id].mid(); _btree(lson,l,mid); _btree(rson,mid+1,r);}int add(int id,int k){ node[id].len --; if(node[id].left == node[id].right) { return node[id].left; } if(k <= node[lson].len)return add(lson,k); else if(node[rson].len >= k-node[lson].len) return add(rson,k-node[lson].len);}int fac[500008];void getfac(){ for(int i=1;i<=500005;i++) for(int j=i;j<=500005;j+=i) fac[j] ++; ;}char a[500100][11];int A[500100];int main(){ int n,m; getfac(); while(~scanf("%d%d",&n,&m)) { _btree(1,1,n); for(int i=1;i<=n;i++)scanf("%s%d",a[i],&A[i]); int Max = -1,pos = 1; int mod = n; for(int i=1;i<=n;i++) { int x = add(1,m); if(fac[i] > Max) { Max = fac[i]; pos = x; } mod--; if(mod == 0)break; if(A[x] > 0) { m = ((m-2+A[x]) % mod + mod) % mod+ 1; } else { m = ((m-1+A[x])%mod + mod) % mod + 1; } } printf("%s %d\n",a[pos],Max); }}
0 0
- POJ Who Gets the Most Candies? 线段树 第 5天
- POJ 2886 Who Gets the Most Candies? 线段树
- poj 2886 Who Gets the Most Candies?(线段树#3)
- POJ 2886 Who Gets the Most Candies? 线段树
- POJ 2886 Who Gets the Most Candies? (线段树)
- POJ 2886 Who Gets the Most Candies?(线段树)
- POJ 2886 Who Gets the Most Candies?(线段树)
- POJ 2886 Who Gets the Most Candies? (线段树)
- Who Gets the Most Candies?+POJ+线段树+反素数
- Who Gets the Most Candies? - POJ 2886 线段树
- poj 2886 Who Gets the Most Candies?(线段树)
- POJ 2886 Who Gets the Most Candies?(线段树)
- POJ - 2886 Who Gets the Most Candies?(线段树)
- POJ - 2886 Who Gets the Most Candies?(线段树)
- POJ 2886 Who Gets the Most Candies?(线段树)
- poj 2886-Who Gets the Most Candies?(线段树)
- POJ Who Gets the Most Candies? 2886(线段树)
- poj 2886 Who Gets the Most Candies?(线段树)
- 解决ubuntu14.04下Qt 5.3.1 下的QtCreator fcitx,ibus不能输入中文
- Android目录结构
- windows mysql提示:1045 access denied for user 'root'@'localhost' using password ye
- 通过用户id输出头像文件流
- Codeforces Round #248 (Div. 2) —— B
- POJ Who Gets the Most Candies? 线段树 第 5天
- IOS中 NSDictionary(字典)排序
- 在Eclipse中离线安装ADT(Android Development Tools)
- GitHub上最火的74个Android开源项目(三)
- ftp批量下载 与单个下载
- c# Bitmap byte[] Stream 文件相互转换
- StringUtils全览
- android学习----主要数据存储方
- FFMPEG详解(soso)