• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
tmeteorj
Nothing is so big that it is impossible to get over, and hurt only serves to make us stronger. 没有什么事是大到无法战胜的,痛苦也只会让我们变得更加坚强。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2012年10月16日

POJ 1974
摘要: 题意:在n*m的地图上,一只虫子找地方睡觉,它一睡就会把自己拉伸到碰到砖块,问它睡觉地方种数。题解:两次sort,依次统计横着睡和竖着睡的种数。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct data 6 { 7 int x,y; 8 }po[140000]; 9 bool comp_x(data a,data b)10 {11 if(a.x!=b.x)12 return a.x<b.x;13 e 阅读全文
posted @ 2012-10-16 20:06 tmeteorj 阅读(387) 评论(0) 推荐(0)
 
POJ 1786
摘要: 题意:给定牌的顺序,然后依次摸牌,最后对每个人的手牌排序输出。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int po[4][14],mp[300]; 6 char getch[500]; 7 void print_1(int a[]) 8 { 9 for(int i=0;i<13;i++)10 printf("|%c %c",getch[a[i]%100],getch[a[i]%100 阅读全文
posted @ 2012-10-16 19:40 tmeteorj 阅读(226) 评论(0) 推荐(0)
 
POJ 3146
摘要: 题意:求杨辉三角形第n+1行中不能被质数p整除的的数的个数。题解:1、杨辉三角形第n+1行的数位:C(n,0)...C(n,n) 2、C(n,m)=n!/(m!(n-m)!),判断其能否被p整除就是看它是否含有因子p,n!中含有n/p+n/p^2+....n/p^k个p,由于C(n,m)是整数,所以不含的情况即n!中含p的个数等于其分子中含p的个数。 3、n/p,n/p^2,n/p^3...n/p^k实际就是n的p进制下的表示时各位的数。 4、假如n的第i位的p进制表示为a,那么要使最后不能被p整除,则分子的第i为的表示也应为a,但分子有m!和(n-m)!构成,实际上可以枚举第i位... 阅读全文
posted @ 2012-10-16 18:09 tmeteorj 阅读(345) 评论(0) 推荐(0)
 
POJ 2799
摘要: 题意:给出n个同属一个网络的IP地址,求其子网掩码以及网络地址。题解:只需知道子网掩码与ip地址按位与后等于同一个值,且子网掩码前面全是1,后面全是0即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct IP 6 { 7 int b[4]; 8 }po[1005]; 9 int lowbit(int x)10 {11 return x&(-x);12 }13 int lg(int x)14 {1 阅读全文
posted @ 2012-10-16 17:44 tmeteorj 阅读(352) 评论(0) 推荐(0)
 
POJ 2718
摘要: 题意:给出最多10个数字,将它们划分为两个整数,求差异值最小的值(除非只有一位数,否则不允许出现先导0)题解:很显然如果总共有n个数,必然有一个整数长n/2,另一个长n-n/2,dfs搜一遍即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int inf=0x3f3f3f3f; 6 int a[12],b[12],n,ans; 7 bool vis[12]; 8 void solve(int aa) 阅读全文
posted @ 2012-10-16 16:27 tmeteorj 阅读(1474) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3