第三题:HDU 4730 We Love MOE Girls

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4730

水题~~~

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std; typedef __int64 xiaohao;
typedef long long LL;
const int N=1090;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-7; char s[N];
char ss[10]="nanodesu";
int main()
{
int T,se=0;
scanf("%d",&T);
while(T--)
{
int m, n;
scanf("%s",s);
int len=strlen(s);
printf("Case #%d: ", ++se);
if(len<4)
{
printf("%s%s\n",s,ss);
continue;
}
if(s[len-1]=='u'&&s[len-2]=='s'&&s[len-3]=='e'&&s[len-4]=='d')
{
for(int i=0;i<len-4;i++)
printf("%c",s[i]);
printf("%s\n",ss);
continue;
} printf("%s%s\n",s,ss); }
return 0;
}

第四题:HDU 4731 Minimum palindrome

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731

题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小,

m等以1时,直接输出n个a,

现在要解决的就是m=2的情况:

通过自己再纸上面写可以得出当n大于等于9时,最大的回文为4,要字典数最小,所以前四个都为a,后面也可以找到一个最小循环结:babbaa

但是还要讨论最后还剩余几个,如果是小于等于两个,那么添加2个a,否则按循环结添加。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std; typedef __int64 xiaohao;
typedef long long LL;
const int N=100090;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-7; const char tab[8][20] =
{ "a", "ab", "aab", "aabb", "aaaba", "aaabab", "aaababb", "aaababbb"}; int main()
{
int T,se=0;
scanf("%d",&T);
while(T--)
{
int m, n;
scanf("%d%d",&m,&n);
printf("Case #%d: ", ++se);
if(m>2)
{
int a = n / 3;
int b = n % 3;
for(int i=0;i<a;i++)
printf("abc");
for(int i=0;i<b;i++)
printf("%c",'a'+i);
printf("\n");
}
else if(m == 1)
{
for(int i=0;i<n;i++)
putchar('a');
printf("\n");
}
else
{
if(n < 9)
{
printf("%s\n", tab[n-1]);
}
else
{
char t[] = "babbaa";
printf("aaaa");
int a = (n-4) / 6;
int b = (n-4) % 6;
for(int i=0;i<a;i++) printf("babbaa");
if(b <= 2) for(int i=0;i<b;i++) putchar('a');
else for(int i=0;i<b;i++) putchar(t[i]);
printf("\n");
}
}
}
return 0;
}

第七题:HDU 4734 F(x)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734

数位DP。

用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小于k的和,然后就很容易想了

dp[i+1][j][k+(1<<i)]=dp[i][j1][k];(0<=j1<=j1)

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std; typedef __int64 xiaohao;
typedef long long LL;
const int N=7000;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-7; int dp[12][12][N];
int tsum[12][12][N];
int w[20]; void init()
{
memset(dp,0,sizeof(dp));
dp[0][0][0]=1;
int n=10;
for(int i=0;i<12;i++)
{
for(int j=0;j<n;j++)
{
for(int k=0;k<N-1;k++)
{
for(int k1=0;k1<n;k1++)
{
int t1=k+k1*(1<<i);
dp[i+1][k1][t1]+=dp[i][j][k];
}
}
}
}
memset(tsum,0,sizeof(tsum));
for(int i=1;i<12;i++)
{
for(int j=0;j<n;j++)
{
for(int k=0;k<N-1;k++)
{
tsum[i][j][k]=tsum[i][j][k-1]+dp[i][j][k];
}
}
}
} int f(int x,int fa)
{
if(x==0) return 0;
int len=0;
int flag=0;
while(x)
{
w[++len]=x%10;
x/=10;
}
int tsum1=0;
for(int i=len;i>=1;i--)
{
for(int k=0;k<w[i];k++)
{
tsum1+=tsum[i][k][fa-flag];
}
flag+=(w[i])*(1<<(i-1));
if(fa<flag)
break;
}
return tsum1;
} int main()
{
init();
int cas;
while(~scanf("%d",&cas))
{
for(int q=1;q<=cas;q++)
{
int a,b;scanf("%d%d",&a,&b);
int len=0;
int fa=0;
while(a)
{
int t1=a%10;
fa+=(1<<(len))*t1;
len++;
a/=10;
}
int ans=f(b+1,fa);
printf("Case #%d: %d\n",q,ans);
}
}
return 0;
}

第十题:HDU 4737  A Bit Fun

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4737

水题,直接暴力~~~~

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std; typedef __int64 xiaohao;
typedef long long LL;
const int N=100090;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-7; #define Maxn 110000
int sa[Maxn]; int main()
{
int t,n,m;
scanf("%d",&t);
for(int ca=1;ca<=t;ca++)
{
int ans=0;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&sa[i]);
for(int i=1;i<=n;i++)
{
int ba=0;
for(int j=i;j<=n;j++)
{
ba|=sa[j];
if(ba>=m)
break;
ans++;
}
}
printf("Case #%d: %d\n",ca,ans);
}
return 0;
}

2013 ACM/ICPC 成都网络赛解题报告的更多相关文章

  1. hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告

    这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...

  2. hdu 4763 && 2013 ACM/ICPC 长春网络赛解题报告

    一个KMP的简单题 不过好久没用过这个东东了,今天写的时候花了很多时间: 只需要花点时间判断下所有的元素都相同的的情况就行了! #include<cstdio> #include<c ...

  3. HDU 4731 Minimum palindrome 2013 ACM/ICPC 成都网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731 题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小 ...

  4. HDU 4734 F(x) 2013 ACM/ICPC 成都网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4734 数位DP. 用dp[i][j][k] 表示第i位用j时f(x)=k的时候的个数,然后需要预处理下小 ...

  5. HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...

  6. 2013 ACM/ICPC 长春网络赛E题

    题意:给出一个字符串,要从头.尾和中间找出三个完全相等的子串,这些串覆盖的区间互相不能有重叠部分.头.尾的串即为整个字符串的前缀和后缀.问这个相同的子串的最大长度是多少. 分析:利用KMP算法中的ne ...

  7. 2013 ACM/ICPC 长春网络赛F题

    题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...

  8. 2013 ACM/ICPC 长沙网络赛J题

    题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字 ...

  9. 2013 ACM/ICPC 南京网络赛F题

    题意:给出一个4×4的点阵,连接相邻点可以构成一个九宫格,每个小格边长为1.从没有边的点阵开始,两人轮流向点阵中加边,如果加入的边构成了新的边长为1的小正方形,则加边的人得分.构成几个得几分,最终完成 ...

随机推荐

  1. sql 查询所有数据库、表名、表字段总结

    ms sql server 1.查询所有表select [id], [name] from [sysobjects] where [type] = 'u' order by [name]2.查询所有数 ...

  2. PHP-购物网站开发设计(一)

    2015-07-6 开始使用PHP完成简单购物网站的设计,首先要选择合适的软件平台,所以今天先记录平台的选择与搭建: 我选择使用Apache24 + PHP 5.6 + MySQL 开发环境完成PHP ...

  3. PGA与SGA

    当用户进程连接到数据库并创建一个对应的会话时,Oracle服务进程会为这个用户专门设置一个PGA区,用来存储这个用户会话的相关内容.当这个用户会话终止时,数据库系统会自动释放这个PAG区所占用的内存. ...

  4. Spark学习资料

    1. 倾情大奉送--Spark入门实战系列 2. Spark GraphX: http://blog.csdn.net/bluejoe2000/article/details/44308167

  5. ASP.NET jQuery 随笔 显示RadioButtonList成员选中的内容和值

    通过jQuery来获取RadioButtonList成员内容. <%@ Page Language="C#" AutoEventWireup="true" ...

  6. mybatis+postgresql平台

    mybatis+postgresql平台        最近有个项目的数据库使用postgresql,使用原生态的mybatis操作数据,原生态的没什么不好,只不过国内有个tk.mybatis的工具帮 ...

  7. JavaEE Tutorials (8) - Java持久化API介绍

    8.1实体96 8.1.1实体类的需求97 8.1.2实体类中的持久化字段和属性97 8.1.3实体的主键101 8.1.4实体关系中的多重性103 8.1.5实体关系中的方向103 8.1.6实体中 ...

  8. JAVA GUI学习 - JFileChooser文件选择器组件学习:未包括JFileChooser系统类学习

    public class JFileChooserKnow { /** * @param args */ public static void main(String[] args) { // TOD ...

  9. 1005 - Rooks(规律)

    1005 - Rooks   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is ...

  10. [cocos2d-x]用CCSpriteBatchNode进行文理贴图的优化

    引言: 我们在进行手机游戏开发的过程中,由于手机的内存资源是有限的,那么对纹理贴图的优化是非常有必要的,有可能相同的功能,优化的好与不好对内存资源的消耗是非常明显的,下面我就用一个例子来说明一下. 说 ...