2013 ACM/ICPC 成都网络赛解题报告
第三题: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 成都网络赛解题报告的更多相关文章
- hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告
这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...
- hdu 4763 && 2013 ACM/ICPC 长春网络赛解题报告
一个KMP的简单题 不过好久没用过这个东东了,今天写的时候花了很多时间: 只需要花点时间判断下所有的元素都相同的的情况就行了! #include<cstdio> #include<c ...
- HDU 4731 Minimum palindrome 2013 ACM/ICPC 成都网络赛
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731 题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小 ...
- 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的时候的个数,然后需要预处理下小 ...
- HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...
- 2013 ACM/ICPC 长春网络赛E题
题意:给出一个字符串,要从头.尾和中间找出三个完全相等的子串,这些串覆盖的区间互相不能有重叠部分.头.尾的串即为整个字符串的前缀和后缀.问这个相同的子串的最大长度是多少. 分析:利用KMP算法中的ne ...
- 2013 ACM/ICPC 长春网络赛F题
题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...
- 2013 ACM/ICPC 长沙网络赛J题
题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字 ...
- 2013 ACM/ICPC 南京网络赛F题
题意:给出一个4×4的点阵,连接相邻点可以构成一个九宫格,每个小格边长为1.从没有边的点阵开始,两人轮流向点阵中加边,如果加入的边构成了新的边长为1的小正方形,则加边的人得分.构成几个得几分,最终完成 ...
随机推荐
- Android百度地图的简单实现
2015-06-13 最近学习了百度地图API的简单开发,现记录如下:(持续更新中) 百度地图API是为开发者免费提供的一套基于百度地图服务的应用接口,包括JavaScript API.Web服务AP ...
- Trie implementation
在学习 Aho - Corasick Automation Algorithm 之前,先学习一下,Trie 的实现过程: The name trie comes from its use for re ...
- jquery的extend()函数
extend()是在写插件的过程中常用的方法,该方法有一些重载原型. 1.该方法的原型是: extend(dest,src1,src2,src3...); 它的含义是将src1,src2,src3.. ...
- 高质量程序设计指南C/C++语言——有了malloc/free为什么还要new/delete?
- [转]swift 学习资源 大集合
今天看到了一个swift的学习网站,里面收集了很多学习资源 [转自http://blog.csdn.net/sqc3375177/article/details/29206779] Swift 介绍 ...
- QT不让windows休眠的方法
对于一些Windows应用程序,必须要保证os不能休眠才能有效工作,如迅雷下载软件,如果os进入休眠,则会导致网络不正常,从而导致不能下载东西.那木有没有1种机制,当打开软件的时候,就自动将os设为不 ...
- Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置
Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置 2013年8月14日Android记录 很多应用都会有用户设置,用户的一些偏好可以由用户来决定 ...
- spring注解controller示例
依赖库 spring 3.0 配置web.xml文件如下: <?xml version="1.0" encoding="UTF-8"?> <w ...
- hdu1395-2^x mod n = 1
http://acm.hdu.edu.cn/showproblem.php?pid=1395 原理为 a ^ b % n == d ; >>>>>> (( a % ...
- 重温 Win32 API ----- 截屏指定窗体并打印
朋友说在一个VC++6.0开发的项目中要增加打印窗体的功能,让帮忙写个代码供其调用. 这么老的IDE当然不想碰了,并且也不喜欢MFC笨拙不清晰的封装.所以决定採用纯Win32 API,然后用C++类简 ...