这次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. Windows的公共控件窗口类列表

    The following window class names are provided by the common control library: ANIMATE_CLASS Creates a ...

  2. Android studio多个项目之间怎么实现快速切换?

    Android studio多个项目之间怎么实现快速切换?Android studio中打开的项目太多了,想切换到一个项目很麻烦,怎么才能快速切换到另一个项目中呢?请看下文详细介绍 在对Android ...

  3. Python 数据处理扩展包: pandas 模块的DataFrame介绍(读写数据库的操作)

    1.读取表中的内容,如下例子: import MySQLdb try: conn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='root ...

  4. Microsoft Visual Studio 发展历史

    Microsoft Visual Studio(简称VS)是美国微软公司的开发工具包系列产品.VS是一个基本完整的开发工具集,它包括了整个软件生命周期中所需要的大部分工具,如UML工具.代码管控工具. ...

  5. 使用zxing生成二维码 - servlet形式

    因为项目有个功能需要打印二维码,因为我比较喜欢使用html+css+js实现,所以首先想到的是jquery.qrcode.js插件,这个插件可以用canvas和table生成二维码,效果也不错,不过对 ...

  6. 用 Python 测试框架简化测试

    用 Python 测试框架简化测试 摘要:本文将向您介绍了三种流行 Python 测试框架(zope.testing,py.test,nose)的基本特性,并讨论新一代的测试风格. 最近出现了行业级的 ...

  7. poj-3899-The Lucky Numbers 模拟+数学

    题目链接: http://poj.org/problem?id=3899 题目意思: 求给定区间内,只含4.7的数的个数以及通过反转后在该区间内的个数和. 解题思路: 模拟+数学. 代码解释的很详细, ...

  8. LeetCodeOJ. String to Integer (atoi)

    试题请參见: https://oj.leetcode.com/problems/string-to-integer-atoi/ 题目概述 Implement atoi to convert a str ...

  9. 新买一款打印机hp5525N

    11900 RMB 彩色.激光.彩打. 让法国的工艺工程师给改成法语的了.

  10. 高级UIKit-05(CoreData)

    [day06_1_CoreDataPerson]:保存person对象到coreData数据库 保存大量数据时用CoreData保存到数据库,数据库会存在documents目录下 操作步骤: 1.创建 ...