【EOJ Monthly 2018.2 (Good bye 2017)】
23333333333333333
由于情人节要回家,所以就先只放代码了。
此题是与我胖虎过不去。
【E. 出老千的 xjj】
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=;
#define ll long long
int i,j,n,k,x;
ll p[maxn+],sum[maxn+],tmp,ans=,Max=;
int main()
{
scanf("%d%d",&n,&k);
for(i=;i<=n;i++){
scanf("%d",&x);
tmp+=x;
p[x]++;
}
if(tmp<=k){
printf("0\n");
return ;
}
for(i=;i<=maxn;i++) {
sum[i]=sum[i-]+p[i]*i;
p[i]+=p[i-];
}
for(i=;i<=maxn;i++){
ll yy=(k-)/i+;
ll xx=n;
tmp=;
//if(k%i==0&&yy<xx) continue;
if(k%i==) continue; //上面的WA了
for(j=;j<maxn/i;j++){
int n1=(j+)*i,n2=j*i+;
if(n2<) n2=;
xx+=(p[n1]-p[n2-]);
tmp+=(p[n1]-p[n2-])*((j+)*i)-sum[n1]+sum[n2-];
if(k%i==&&yy<xx) break;
if(tmp>ans) break;
}
if((k%i==&&xx<=yy)||k%i!=){
ans=min(ans,tmp);
}
}
cout<<ans<<endl;;
return ;
}
【A2】
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int n,k,p;
int num[]={,,,,,},cost[];
long long f[];
int main(){
scanf("%d%d%d",&n,&k,&p);
for(int i=;i<=k;i++){
long long temp=1LL*i*p;
for(int j=;j<=;j++)
if(temp>=num[j]){
cost[i]+=temp/num[j];
temp%=num[j];
}
}
memset(f,,sizeof(f));
f[]=;
for(int i=;i<=;i++)
for(int j=max(,i-k);j<i;j++)
f[i]=min(f[i],f[j]+cost[i-j]);
if(n<=){
cout<<f[n]<<endl;
return ;
}
int way=;
for(int i=;i<=k;i++)
if(1.0*i/cost[i]>1.0*way/cost[way])
way=i;
int t1=n/way,t2=n%way;
long long ans=1LL*t1*cost[way]+f[t2];
for(int i=;i<=;i++){
t1=n/way-i;
t2=n-way*t1;
ans=min(ans,1LL*t1*cost[way]+f[t2]);
}
cout<<ans<<endl;
return ;
}
【B】
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int N,sta[];
int f[];
struct edge{
int x,y;
}e[];
int have[][],cnt[];
int check(int x,int s){
bool flag=;
for(int i=;i<=cnt[x];i++)
if(s&sta[have[x][i]]){
flag=;
break;
}
if(!flag)
return -;
for(int i=;i<=cnt[x];i++)
if(s&sta[have[x][i]])
s^=sta[have[x][i]];
return s;
}
int dfs(int s){
if(f[s]!=-)
return f[s];
for(int i=;i<=N;i++){
int temp=check(i,s);
if(temp!=-)
if(!dfs(temp))
return f[s]=;
}
return f[s]=;
}
int main(){
sta[]=;
for(int i=;i<=;i++)
sta[i]=sta[i-]*;
scanf("%d",&N);
for(int i=;i<N-;i++){
scanf("%d%d",&e[i].x,&e[i].y);
have[e[i].x][++cnt[e[i].x]]=i;
have[e[i].y][++cnt[e[i].y]]=i;
}
memset(f,-,sizeof(f));
f[]=;
if(dfs(sta[N-]-))
printf("First\n");
else
printf("Second\n");
return ;
}
【F】
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
const int maxn=;
int main()
{
int T;
double a,b,c,x,y,z;
while(~scanf("%lf%lf%lf",&x,&y,&z)){
a=(2.0*y-z+x)/2.0;
b=x-a;
c=(z-a-b)/2.0;
if(a<=||b<=||c<=) printf("Wrong\n");
else printf("%.6lf\n",a);
} return ;
}
【EOJ Monthly 2018.2 (Good bye 2017)】的更多相关文章
- 【EOJ Monthly 2018.7】【D数蝌蚪】
https://acm.ecnu.edu.cn/contest/92/problem/D/ D. 数蝌蚪 Time limit per test: 2.0 seconds Memory limit: ...
- EOJ Monthly 2018.8 D. Delivery Service-树上差分(边权/边覆盖)(边权转点权)(模板题)
D. Delivery Service 单测试点时限: 2.5 秒 内存限制: 512 MB EOJ Delivery Service Company handles a massive amount ...
- EOJ Monthly 2018.7
准备继续大学acm啦 又要开始愉快的码码码啦 第一次在华东师大OJ上面做题 看来EOJ上的积分体质是假的,我怎么一把上红??? A.数三角形 神tm的防AK题放在A,出题人很不友好啊... 先写了个暴 ...
- EOJ Monthly 2018.4
A. ultmaster 的小迷妹们 Time limit per test: 2.0 seconds Memory limit: 256 megabytes ultmaster 男神和他的小迷妹们准 ...
- EOJ Monthly 2018.4 (E.小迷妹在哪儿(贪心&排序&背包)
ultmaster 男神和小迷妹们玩起了捉迷藏的游戏. 小迷妹们都希望自己被 ultmaster 男神发现,因此她们都把自己位置告诉了 ultmaster 男神,因此 ultmaster 男神知道了自 ...
- [EOJ Monthly 2018.10][C. 痛苦的 01 矩阵]
题目链接:C. 痛苦的 01 矩阵 题目大意:原题说的很清楚了,不需要简化_(:з」∠)_ 题解:设\(r_i\)为第\(i\)行中0的个数,\(c_j\)为第\(j\)列中0的个数,\(f_{i,j ...
- EOJ Monthly 2018.11 D. 猜价格
猜价格 分两种情况讨论: k≤n,先猜至多 k 次 1,由于回答 <1 肯定是假的,所以可以把剩余系下是哪次错试出来,然后用至多 n 次搞定. k>n,每个数都猜两次,如果两次结果不一样, ...
- EOJ Monthly 2018.7 B.锐角三角形(数学几何+思维)
描述 是否存在面积为S/2的整点锐角三角形?存在输出Yes并输出三个整点坐标,否则输出No. 注意如果存在输出的坐标必须在long long范围内. Input 第一行一个整数S(1<=S< ...
- EOJ Monthly 2018.11 猜价格 (模拟)
分三种情况: 1.k=1.此时每次都说反话,反着二分即可. 2.1<k <= n.那么在前n次问答中一定会出现一次错误,通过不断输出1找出那个错误发生的位置(若回答是>那这就是错误) ...
随机推荐
- Swift oc 混编 - oc导入Swift协议
(默认已经设置好桥接头文件)1.在Swift文件中写好协议2.oc类文件中导入:"项目名-swift.h"格式的文件 即:#include "项目名-swift.h&qu ...
- Jquery:怎样让子窗体的div显示在父窗体之上
<1> js或者jQuery訪问页面中的框架iframe. 注意:框架内的页面是不能跨域的! 如果有两个页面,在同样域下. 如果:父窗体 index.html ,有id 为 subif ...
- hdu5340 Three Palindromes(manacher算法)
题目描写叙述: 推断能否将字符串S分成三段非空回文串. 解题思路: 源码: #include <cstdio> #include <algorithm> #define MAX ...
- vue2.0 自定义 侧滑删除(LeftSlider)组件
1.自定义侧滑删除组件 LeftSlider.vue <!-- 侧滑删除 组件 --> <template> <div class="delete"& ...
- vscode 插件安装以及首选项配置
1.插件 Auto Close Tag Path Intellisense Prettier Vetur vscode-icons Bracket Pair Colorizer 2.vscode 首选 ...
- ssm 网页
http://stackoverflow.com/questions/14545872/bean-named-xxx-must-be-of-typexxx-but-was-actually-of-ty ...
- Linux 磁盘空间查询&&解决Linux 中“磁盘空间不足”的问题
一.linux 查看目录的剩余空间大小 两个命令df .du结合比较直观 df -h 查看整台服务器的硬盘使用情况 du -lh --max-depth=1 : 查看当前目录下一级子文件和子目录占用的 ...
- Java、C++、Python、Ruby、PHP、C#和JavaScript的理解
Java.C++.Python.Ruby.PHP.C#和JavaScript和日本动漫里的那些大家熟悉的动漫人物结合起来.依据他们的身世.个人经历来生动的表达各编程语言的发展历程.原文内容例如以下: ...
- python訪问redis
python訪问redis 1 Linux上安装redis a) 下载 $ wget http://download.redis.io/releases/redis-3.0.5.tar.gz b) 编 ...
- Java泛型擦除
Java泛型擦除: 什么是泛型擦除? 首先了解一下什么是泛型?我个人的理解:因为集合中能够存储随意类型的对象.可是集合中最先存储的对象类型一旦确定后,就不能在存储其它类型的对象了,否则,编译时不会报错 ...