第三题: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. POJ 1459 Power Network(网络流 最大流 多起点,多汇点)

    Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 22987   Accepted: 12039 D ...

  2. HDU 4861 Couple doubi(找规律|费马定理)

    Couple doubi Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  3. AsyncSocket 使用

    今天使用AsyncSocket模拟及时通信,在这里记录一下,免得以后自己又犯相同的错误 1>创建客户端和服务器socket /** * 设置socket */ - (void)setupSock ...

  4. 开始学习Lucene

    最近百度的魏则西事件闹的沸沸扬扬,突然有个想法:是否百度的中文搜索目前还没有人能挑战它的地位呢? 哈哈,想的太多了,正巧毕业设计就和搜索有关,当时只是大致了解了概念:如分词.排序.索引.爬虫等,并以此 ...

  5. C++ const 限定符

    C++ const 限定符 作用:把一个对象转换成一个常量 用法:const type name = value; 性质:1. 定义时必须初始化,定义后不能被修改.2. 类中的const成员变量必须通 ...

  6. 网络编程——TCP连接

    TCP在双方传输数据前,发送方先请求建立连接,接收方同意建立连接后才能传输数据.(打电话:先拨号,等对方同意接听后,才能交流)...高可靠性 UDP不需要建立连接(发短信).不可靠,可能出现数据丢失等 ...

  7. ASP.NET MVC 中的 T4

    每次使用“添加视图”或“添加控制器”功能时,您都在 ASP.NET MVC 项目中使用 T4 模板.这些模板位于 Common7\IDE\ItemTemplates\CSharp\Web\MVC 2\ ...

  8. VS2008一个小bug

    vc工程的项目属性里MFC的使用有三项:默认“使用标准windows库”,修改为“在静态库中使用MFC”,然后再改回默认,项目变化如下: 今天的工程在改过后编译不能通过,手工把0改回2(1改回3)后O ...

  9. linux文件系统操作——底层文件访问

        在不使用标准I/O的情况下,使用write,read,open实现对文件的复制操作,这些调用都是直接使用底层系统调用,完成从用户代码到内核代码的切换,消耗大量的系统资源,今天对此进行研究主要是 ...

  10. linux-0.11抠代码-GDB+VMWARE

    vmware新建一个虚拟机,硬盘为0.1G,建立完成后要先启动一次虚拟机,此时无任何系统,然后再关闭,应该会多出一个ostest-flat.vmdk这个虚拟磁盘文件,下面要用到 新建完成后 我的虚拟机 ...