2014牡丹江亚洲区域赛邀请赛

B题:图论题目

题解这里

K题:想法题

分析:两种变化。加入和交换。首先:星号是n的话最少须要的数字是n+1,那么能够首先推断数字够不够,不够的话如今最前面添数字,假设满足的话直接模拟假设数字不够的话把当前的星号和最后一个数字交换就可以。

css函数能够不用。

AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std; int ccs(string s)
{
int ans=0,tmp = 0;
for(int i=0;i<s.size();i++)
{
if(s[i]=='*')
{
if(tmp<2)
{
ans+=(2-tmp);
tmp = 1;
//printf("YES%d\n",i);
}
else
{
tmp--;
//printf("NO\n");
}
}
else
tmp++;
}
return ans;
} int check(string s,int x)
{
for(int i = s.size()-1;i>x;i--)
{
if(s[i]!='*')
return i;
}
return 0;
}
int solve(string s)
{
int len = s.size(),ans=0,tmp = 0;
for(int i=0;i<len;i++)
{
if(s[i]=='*')
tmp++;
}
int pps = 0;
if((tmp+tmp+1)>len)
{
pps = tmp+tmp+1 - len;
ans+=pps;
}
//printf("%d %d %d\n",tmp,ans,pps);
for(int i=0;i<s.size();i++)
{
if(s[i]=='*')
{
if(pps>=2){
pps--;
}
else
{
ans++;
int f = check(s,i);
swap(s[i],s[f]);
i--;
//cout<<s<<endl;
}
}
else
pps++;
}
return ans;
}
int main()
{
//freopen("Input.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
string s;
cin>>s;
//printf("CCS:%d\n",ccs(s));
int ans = min(solve(s),ccs(s));
printf("%d\n",ans);
}
return 0;
}

I题:直接套用给出的第二个公式。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int n;
double a[200];
double solve(int x)
{
double ans = 0;
for(int i=1;i<=n;i++)
{
double tmp = 0;
if(a[i]==0)
continue;
if(x==2)
tmp = a[i]*log2(a[i]);
else if(x==5)
tmp = a[i]*log(a[i]);
else if(x==10)
tmp = a[i]*log10(a[i]);
//printf("TMP%lf, %lf\n",tmp, log2(a[i]));
ans+=tmp;
}
return ans;
}
int main()
{
//freopen("Input.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
int x;
string s;
cin>>n>>s;
for(int i=1;i<=n;i++){
scanf("%d",&x);
a[i]=(double)x/100;
}
double ans=0;
if(s=="bit")
ans = solve(2);
else if(s=="nat")
ans = solve(5);
else
ans = solve(10);
printf("%.12lf\n",-ans);
}
return 0;
}

A题:水题。

求出第一个班的平均值 x 和第二个平均值 y ,假设 x 为整数则x -- 。y 变整数之后+1.就是ans

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m;
scanf("%d%d",&n,&m);
int sum1=0,sum2=0;
for(int i=1;i<n;i++)
{
int x;scanf("%d",&x);
sum1+=x;
}
for(int i=0;i<m;i++)
{
int x;
scanf("%d",&x);
sum2+=x;
}
double p1 = (double)sum1 / (n-1);
double p2 = (double)sum2 / m;
//printf("%.5lf %.5lf\n",p1,p2);
int mi = p1,ma = (int)p2+1;
if(mi == p1)
mi--;
printf("%d %d\n",min(mi,ma),max(mi,ma)); }
return 0;
}

The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 【部分题解】的更多相关文章

  1. hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi'an Online)

    Mart Master II Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  2. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest A.Average Score B.Building Fire Stations C.Card G ...

  3. HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP

    Clone Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Submiss ...

  4. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...

  5. ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków

    ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...

  6. 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)

    2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...

  7. 2018 ICPC Pacific Northwest Regional Contest I-Inversions 题解

    题目链接: 2018 ICPC Pacific Northwest Regional Contest - I-Inversions 题意 给出一个长度为\(n\)的序列,其中的数字介于0-k之间,为0 ...

  8. 2014 ACM/ICPC Asia Regional Shanghai Online

    Tree http://acm.hdu.edu.cn/showproblem.php?pid=5044 树链剖分,区间更新的时候要用on的左++右--的标记方法,要手动扩栈,用c++交,综合以上的条件 ...

  9. HDU 5029 Relief grain(离线+线段树+启发式合并)(2014 ACM/ICPC Asia Regional Guangzhou Online)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5029 Problem Description The soil is cracking up beca ...

  10. 2014 ACM/ICPC Asia Regional Guangzhou Online

    Wang Xifeng's Little Plot http://acm.hdu.edu.cn/showproblem.php?pid=5024 预处理出每个点八个方向能走的最远距离,然后枚举起点,枚 ...

随机推荐

  1. C++派生类继承父类修饰符

    公式: 继承成员对外的访问属性 = Max{继承方式,父类成员访问级别}: 1.如果子类从父类继承时使用的继承限定符是public,那么(1)父类的public成员成为子类的public成员,允许类以 ...

  2. 暑假集训 || 区间DP

    区间DP 经典石子合并问题V1    复杂度 On3 int a[SZ], sum[SZ], f[SZ][SZ]; int main() { int n; scanf("%d", ...

  3. The MySQL server is running with the –secure-file-priv

    show variables like '%secure%'; 将文件导出路径更改为查询到的secure-file-priv路径下 select * from table where column = ...

  4. typedef重复定义 和 error: ‘long long long’ is too long for GCC

    今天发现一个很有意思的编译问题,然后在Stack Overflow上也有看到类似的.就是出现了 long long long 类型错误提示 错误提示如下: /home/yejy/algorithm_a ...

  5. 查询SYS_ORG_TB树的层级

    WITH N(SYS_ORG_ID,SYS_ORG_NAME,LEVEL) AS( AS LEVEL FROM SYS_ORG_TB WHERE SYS_ORG_UPID IS NULL UNION ...

  6. Django框架基础知识02-路由及渲染

    1.URL(Uniform Resoure Locator)统一资源定位符是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示,是互联网上标准资源的地址.互联网上的每个文件都有一个唯一的URL ...

  7. LeetCode(86) Partition List

    题目 Given a linked list and a value x, partition it such that all nodes less than x come before nodes ...

  8. 关于markdown 的简单使用(已更新)

    markdown的介绍 Markdown是一种可以使用普通文本编辑器编写的标记语言,通过类似HTML的标记语法,它可以使普通文本内容具有一定的格式. Markdown具有一系列衍生版本,用于扩展Mar ...

  9. luogu3415 祭坛

    先二分答案转化成判定问题. 考虑拿一根扫描线从 \(x=0\) 扫到 \(x=n\),每次移动扫描线更新每个位置它上面的点数和下面的点数,这样可以确定在当前的扫描线上哪些位置对于 \(y\) 轴方向是 ...

  10. angularjs ng-repeat下验证问题

    angularjs验证要求name唯一,repeat情况,name 等通过${index}等绑定,也无法获取值 通过ng-from的方法,这样验证name重复也可以了. <ng-form nam ...