这次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. LOVEU

    闲来无事,自己编写一个小程序,自娱自乐 //date: 2013/8/14 //designer :pengxiaoen //function : printf the word love #incl ...

  2. 使用Android studio下载github上的工程及问题解决

    Android studio内置了github的插件,可以直接下载github上的工程,感觉好爽啊.具体怎么做呢?1.如图所示操作,如果是初次使用会提示输入用户名密码. 2.等android stud ...

  3. Scriptcase在线试用开发环境

    现在,你可以通过浏览器在线试用的方式,体验Scriptcase的高效快速开发方式. 只需要有上网环境就可以使用: 兼容几乎所有的浏览器(IE.Firefox.Chrome.Opera……): 客户端无 ...

  4. Hdu 1175 连连看(DFS)

    Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1175 因为题目只问能不能搜到,没问最少要几个弯才能搜到,所以我采取了DFS. 因为与Hdu ...

  5. uva 816 - Abbott&#39;s Revenge(有点困难bfs迷宫称号)

    是典型的bfs,但是,这个问题的目的在于读取条件的困难,而不是简单地推断,需要找到一种方法来读取条件.还需要想办法去推断每一点不能满足条件,继续往下走. #include<cstdio> ...

  6. VS2010 ,工程文件减肥

    写一个bat文件来清理VS2010工程文件. 将其放入到工程文件夹下,双击即可自动将sdf,ipch等占用空间很大的文件删除. 这样的方式较之于转移浏览数据库文件的位置而言更为灵活一些,不用特别的设置 ...

  7. 64位CentOS6.2安装erlang及rabbitmqServer

    CentOS 6.2 64bit 安装erlang及RabbitMQ Server 1.操作系统环境(CentOS 6.2 64bit) [root@HAproxy ~]# cat /etc/issu ...

  8. 【Cron Expressions】Quartz Scheduler 2.1.x 英文节选

    Cron Expressions Cron-Expressions are used to configure instances ofCronTrigger. Cron-Expressions ar ...

  9. H3C HCSE 官方培训胶片(中文) 下载

    H3C HCSE 官方培训胶片(中文) 点击文件名下载 HM-040 OSPF路由协议(V5.1).ppt HM-041 BGP协议原理及配置(V5.0).ppt HM-041 BGP协议原理及配置( ...

  10. HDURevenge of Segment Tree(第二长的递增子序列)

    HDURevenge of Segment Tree(第二长的递增子序列) 题目链接 题目大意:这题是求第二长的递增子序列. 解题思路:用n^2的算法来求LIS,可是这里还要记录一下最长的那个序列是否 ...