第三题: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. 【转】QT QString, wchar_t *, TCHAR, CString和其他字符或字符串类型的转化

    //QString to wchar_t *: const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(fileNa ...

  2. BZOJ 2301 Problem b(莫比乌斯反演+分块优化)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=37166 题意:对于给出的n个询问,每次求有多少个数对(x,y),满 ...

  3. servlet三种实现方式之三通过继承HttpServlet开发servlet

    servlet有三种实现方式: 1.实现servlet接口 2.继承GenericServlet 3.通过继承HttpServlet开发servlet 第三种: import java.io.*; i ...

  4. [LeetCode]题解(python):068-Text Justification

    题目来源: https://leetcode.com/problems/text-justification/ 题意分析: 输入一个字符串数组和一个规定长度L.将这个字符串数组的元素尽可能放到长度的L ...

  5. 删除Mac中所有 .DS_Store 隐藏文件

    删除Mac中所有 .DS_Store 隐藏文件 35•36509感谢 longago 分享于 2012-07-06 12:01|只看该作者|倒序浏览|打印 Safari 5.1.7 Mac OS X ...

  6. 01-C语言基本知识

    目录: 一.C语言基本知识 二.C语言概述 回到顶部 一.C语言基本知识 1 语言背景 1946年,美国冯·诺依曼第一台计算机. 四大部分:中央处理器(控制器,运算器),存储器,输入设备,输出设备. ...

  7. 高质量程序设计指南C/C++语言——C++/C常量(2)

  8. 射频识别技术漫谈(14)——Mifare S50与S70的存取控制

    存取控制指符合什么条件才能对卡片进行操作. S50和S70的块分为数据块和控制块,对数据块的操作有“读”.“写”.“加值”.“减值(含传输和存储)”四种,对控制块的操作只有“读”和“写”两种. S50 ...

  9. Protel99se教程九:protel99se中PCB设计的高级应用

    在上一节我们PCB资源网的protel99se教程当中,我们给大家讲解了在protel99se进行原理图设计中的一些高级应用技巧,在这一节protel99se教程当中,我们将给大家讲解的是,在prot ...

  10. (C#)Windows Shell 编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令

    原文(C#)Windows Shell 编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令 (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢-) 接上一节:( ...