这次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. Week11(11月18日)

    Part I:检查 =========================== 1.上堂课的练习效果. Part II:案例学习 =========================== MusicStor ...

  2. Delphi_MemoryModule — load DLL from memory. Also includes hooking utilities.

    https://github.com/Fr0sT-Brutal/Delphi_MemoryModule

  3. MySQL教程及经常使用命令1.1

    在线教程 21分钟 MySQL 新手教程 w3school在线教程(MYSQL) 变量 查看系统变量 show global variables 查看详细变量 show global variable ...

  4. 如何将UISearchBar上"Cancel"按钮改为”取消“?

    别说话,直接上代码 for (id obj in [searchBar subviews]) {        if ([obj isKindOfClass:[UIView class]]) {    ...

  5. linux指令(目录类操作指令)

    pwd 显示当前所在的工作目录 cd 目标目录    例如cd  /boot/grub 从当前目录切换到某个目录 cd  切换到根目录 cd.. 切换到当前目录的上层目录 ls  显示当前目录下的内容 ...

  6. 排行榜妙用——CSS计数器

    碰到的坑 小伙伴你们是否有碰到以下的情况,排行榜前3名的样式不一样,你们是怎么处理的么?

  7. Qt国际化(Q_DECLARE_TR_FUNCTIONS() 宏给非Qt类添加翻译支持,以前没见过QTextEncoder和QTextDecoder和QLibraryInfo::location()和QEvent::LanguageChange)

    Internationalization with Qt 应用程序的国际化就是使得程序能在国际间可用而不仅仅是在本国可用的过程. Relevant Qt Classes andAPIs 以下的类支持Q ...

  8. svn回滚版本1

    我刚开始使用SubVersion时, 想把svn代码库回滚到以前某个版本,  上网找来找去都找不到(那时文档比较少), 让我郁闷了好一阵子.  现在记录一下 SubVersion回滚的方法: 第一种方 ...

  9. ESRI Shapefiles (SHP)

    ESRI Shapefiles (SHP) Also known as ESRI ArcView Shapefiles or ESRI Shapefiles. ESRI is the company ...

  10. cocos2d-x环境的搭建之xcode-本人亲历成功搭建!

    cocos2d-x环境的搭建之xcode-本人亲历成功搭建! 写给大家的前言,在学习cocos2d-x的时候自己走了很多的弯路,也遇到了很多很多问题,不管是简单的还是困难的现在都慢慢的一步一步克服了, ...