这次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. 全栈project师的悲与欢

    从小米辞职出来创业的两个多月里,通过猎头或自己投简历,先后面试了知乎,今日头条,豌豆荚,美团,百度,App Annie,去哪儿,滴滴打车等技术团队,一二面(技术面)差点儿都轻松的过了,三面却没有毕业那 ...

  2. bootloader启动代码init.s解析----IRQ中断处理函数

    bootloader启动代码init.s解析----IRQ中断处理函数 init.s源代码如下: ;///////////////////////////////////////////// ;opt ...

  3. iOS 用GDataXMLNode创建和解析XML

    原文地址:http://blog.csdn.net/gf771115/article/details/7718403 NSError *error; //    NSString *path = [[ ...

  4. 算法之旅,直奔<algorithm>之十 count_if

    count_if(vs2010) 引言 这是我学习总结<algorithm>的第十篇,这个重要的地方是设置条件.用的还是蛮多的.(今天下午挺恶心的,一下午就做一个面试题,调代码调傻了... ...

  5. javascript获取页面各种高度

    网页可见区域宽: document.body.clientWidth网页可见区域高: document.body.clientHeight网页可见区域宽: document.body.offsetWi ...

  6. c语言,enum

    在设置错误代号时,使用enum比宏更好看. #include <stdio.h> typedef enum { retOK = 0, errComInterruption = 0x1000 ...

  7. Windows cmd

    windows常用命令 http://www.cnblogs.com/kekec/p/3662125.htmlwindows批处理语法 http://www.cnblogs.com/kekec/p/3 ...

  8. jquery实现ajax提交form表单的方法总结

    本篇文章主要是对jquery实现ajax提交form表单的方法进行了总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助 方法一:  function AddHandlingFeeToRefund( ...

  9. perl json模块

    JSON - JSON (JavaScript Object Notation) encoder/decoder 简介: use JSON; # imports encode_json, decode ...

  10. Java的LockSupport.park()实现分析

    LockSupport类是Java6(JSR166-JUC)引入的一个类,提供了主要的线程同步原语.LockSupport实际上是调用了Unsafe类里的函数,归结到Unsafe里,仅仅有两个函数: ...