这次CF状态之悲剧,比赛就别提了。后来应该好好总结。

A题:某个细节没考虑到,导致T了

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int a[4],b[4],n;
int main()
{
while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF)
{
scanf("%d%d%d",&b[0],&b[1],&b[2]);
scanf("%d",&n);
int suma=a[0]+a[1]+a[2];
int sumb=b[0]+b[1]+b[2];
int res=n-((suma-1)/5+1);
if(res<0)
{
printf("NO\n");
continue;
}
if(suma==0)
res=n;
if(sumb&&(sumb-1)/10+1>res)
{
printf("NO\n");
continue;
}
printf("YES\n");
}
return 0;
}

B题:最開始竟然以为要用后缀数组那些。结果~大水题一个。须要注意的是对于题目所给的用后缀自己主动机的方案,应该考虑相对顺序。即能够删除中间的某些值,达到变换到所要求字符串的目的。

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=200;
char stra[maxn],strb[maxn];
int cnt[2][30];
int main()
{
while(scanf("%s%s",stra,strb)!=EOF)
{
memset(cnt,0,sizeof(cnt));
if(strstr(stra,strb)!=NULL)
{
printf("automaton\n");
continue;
}
int now=0;
int lena=strlen(stra);
int lenb=strlen(strb);
for(int i=0;i<lena;i++)
if(stra[i]==strb[now])
{
now++;
if(now==lenb)
break;
}
if(now==lenb)
{
printf("automaton\n");
continue;
}
for(int i=0;i<lena;i++)
cnt[0][stra[i]-'a']++;
for(int i=0;i<lenb;i++)
cnt[1][strb[i]-'a']++;
bool is=false;
for(int i=0;i<27;i++)
if(cnt[0][i]!=cnt[1][i])
{
is=true;
break;
}
if(!is)
{
printf("array\n");
continue;
}
is=false;
for(int i=0;i<27;i++)
if(cnt[0][i]<cnt[1][i])
{
is=true;
break;
}
if(!is)
{
printf("both\n");
continue;
}
printf("need tree\n");
}
return 0;
}

C题:比赛的时候我都不知道在想什么,比較简单的一个题,分治贪心就好

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int inf=1<<29;
const int maxn=5100;
int n,a[maxn];
int DFS(int sl,int sr)
{
if(sl>sr)
return 0;
int mini=inf,ans=0;
for(int i=sl;i<=sr;i++)
mini=min(mini,a[i]);
for(int i=sl;i<=sr;i++)
a[i]-=mini;
ans+=mini;
int l=sl;
for(int i=sl;i<=sr;i++)
if(!a[i])
{
ans+=DFS(l,i-1);
l=i+1;
}
if(l<=sr)
ans+=DFS(l,sr);
return min(ans,sr-sl+1);
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
int mini=inf;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("%d\n",DFS(1,n));
}
return 0;
}

D题:二分查找

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
long long n,m,k;
bool check(long long val)
{
long long ans=0;
for(int i=1;i<=n;i++)
ans+=min(m,val/i);
return ans>=k;
}
int main()
{
while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
{
long long l=0,r=n*m,ans;
while(l<=r)
{
long long mid=(l+r)>>1;
if(check(mid))
{
ans=mid;
r=mid-1;
}
else
l=mid+1;
}
printf("%I64d\n",ans); }
return 0;
}

E题:这个题须要各种优化,个人认为。

首先应该考虑对1的特殊处理,由于1下去不管怎样都是1。所以应该直接输出即可。对于其他素数的情况也能够直接输出答案(注意输出1),应为它中间不会再有其他因子(除了1以外)。

然后剩下的就是优化各种细节,比方当当前的数大于1e5的时候,以及对k=0与k>1e5的特殊处理

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxm=1e5;
long long x,k,cnt=0;
vector<long long> g;
void DFS(long long u,long long index)
{
if(cnt>=maxm)
return;
if(index==0)
{
cnt++;
printf("%I64d ",u);
return;
}
if(u==1)
{
printf("1 ");
cnt++;
return;
}
int last=0;
for(int i=0;u>=g[i]&&i<g.size();i++)
if(u%g[i]==0)
{
if(last==0&&u!=1&&u==g[i])
{
for(int j=0;j<index-1;j++)
{
printf("1 ");
if(++cnt>=maxm)
return;
}
printf("%I64d ",g[i]);
cnt++;
return;
}
last=i;
DFS(g[i],index-1);
if(cnt>=maxm)
return;
}
}
int main()
{
while(scanf("%I64d%I64d",&x,&k)!=EOF)
{
g.clear();
cnt=0;
if(k==0)
{
printf("%I64d",x);
continue;
}
if(x==1)
{
printf("1");
continue;
}
if(k>maxm)
{
printf("1");
for(long long i=0;i<maxm-1;i++)
printf(" 1");
printf("\n");
}
else
{
long long up=x+1,sq=sqrt(x)+1;
for(long long i=1;i<min(up,sq);i++)
if(x%i==0)
{
if(x/i!=i)
g.push_back(x/i);
g.push_back(i);
up=x/i;
}
sort(g.begin(),g.end());
for(int i=0;i<g.size();i++)
DFS(g[i],k-1);
}
printf("\n");
}
return 0;
}

Codeforces Round #256 (Div. 2)总结的更多相关文章

  1. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  2. Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)

    题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...

  3. Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)

    解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 ...

  4. Codeforces Round #256 (Div. 2) 题解

    Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Codeforces Round #256 (Div. 2) A. Rewards

    A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  6. Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法

     D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...

  7. Codeforces Round #256 (Div. 2) D. Multiplication Table

    主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cm ...

  8. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)

    解题报告 意思就是说有n行柜子,放奖杯和奖牌.要求每行柜子要么全是奖杯要么全是奖牌,并且奖杯每行最多5个,奖牌最多10个. 直接把奖杯奖牌各自累加,分别出5和10,向上取整和N比較 #include ...

  9. Codeforces Round #256 (Div. 2) D. Multiplication Table 很有想法的一个二分

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

  10. Codeforces Round #256 (Div. 2)A-D

    题目连接:http://codeforces.com/contest/448 A:给你一些奖杯与奖牌让你推断能不能合法的放在给定的架子上.假设能够就是YES否则就是NO. <span style ...

随机推荐

  1. struts2上传图片

    在WEB-INF下新建一个content目录,建立一个upload.jsp <%@ page contentType="text/html; charset=UTF-8" l ...

  2. DE1-SOC的sof文件无法下载解决办法

    按照前面友晶科技的文档介绍一步步的做,后面发现根本无法下载sof文件. 通常思维: 一,器件选错了.器件选择错误会导致sof文件无法下载,至于这个ID具体怎么识别我没有追究.如果是这种错误Quartu ...

  3. Directshow 通过 put_Owner 指定显示窗口后,自动刷新问题

    在Directshow中,我们可以对render指定显示窗口,在写程序的过程中, 发现通过put_Owner设置的显示窗口存在自动刷新问题,譬如窗口被遮挡然后再次露出时,被遮挡部分不能自动刷新,需要拖 ...

  4. [LeetCode] Decode Ways [33]

    题目 A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A ...

  5. PS图片

    第二次练习PS,不知道找什么图片,就这么做着吧.然后自己学习了下动画制作,但是中间有些问题,需要再研究研究. 像 CS6中新建蒙版文档,画出的图形单位是厘米,怎么改为像素?(答案看后续博客....)

  6. tweenanim动画

    1.视图 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...

  7. 极光IM使用教程-极光推送

    链接地址:http://jingyan.baidu.com/article/a948d65178a6ea0a2ccd2e7e.html 极光IM使用教程,如果您的 App 需要同时集成 Push 功能 ...

  8. 基于Zlib算法的流压缩、字符串压缩源码

    原文:基于Zlib算法的流压缩.字符串压缩源码 Zlib.net官方源码demo中提供了压缩文件的源码算法.处于项目研发的需要,我需要对内存流进行压缩,由于zlib.net并无相关文字帮助只能自己看源 ...

  9. [置顶] think in java interview-高级开发人员面试宝典(八)

    面经出了7套,收到许多读者的Email,有许多人说了,这些基础知识是不是为了后面进一步的”通向架构师的道路“做准备的? 对的,你们没有猜错,就是这样的,我一直在酝酿后面的”通向架构师的道路“如何开章. ...

  10. js判断是否为pc端或移动端

    function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android" ...