• 博客园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月17日

POJ 3012
摘要: 题意:对于杨辉三角形的第n行,首先但看每一位,将其补成长度为k的数(左补0),然后将这一行连起来作为一个大数,求这个大数mod m。题解:数学公式推导题 1、补0实际上就是使得这个数左边的那个数乘以10的次方,那么最后答案就是Σ(C(n,m)*10^( (n-m)*k ) )%m 2、10^(n-m)k=(10^k)^(n-m),又有个C(n,m),正好组成二项式(1+10^k)^n的展开式 3、于是两个快速幂取模就可以解决了。 PS:不知样例有多少,这种复杂度也能达到500MS+,快速幂取模写怂了的没准还过不了= =! View Code 1 #include<cstd... 阅读全文
posted @ 2012-10-17 21:14 tmeteorj 阅读(169) 评论(0) 推荐(0)
 
POJ 3656
摘要: 题意:扔石子打水漂游戏,四个参数评判好坏,跳跃次数,最后在水中位置,初始位置,和单步跳跃长度,除了最后一项,其他都是越大越好,求最好的扔法。题解:数据也太小了吧。。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct data 6 { 7 int ct,len,ip,sk; 8 bool operator<(const data &ne)const 9 {10 if(ct!=ne.ct)11 . 阅读全文
posted @ 2012-10-17 19:47 tmeteorj 阅读(191) 评论(0) 推荐(0)
 
POJ 3326
摘要: 题意:给出每个人在某台电脑的登录时间与下线时间,求在某个时间段某个人的上线时间。题解:大模拟~可以先记录每个人的上下线时间点,看做一个区间的左右界限,然后记录区间深度,如果到某个时间点时,区间深度大于0,就说明这个人在线,否则,就不在。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<vector> 5 using namespace std; 6 struct data 7 { 8 int p,t; 9 bool lg;10 dat 阅读全文
posted @ 2012-10-17 19:11 tmeteorj 阅读(277) 评论(0) 推荐(0)
 
POJ 3232
摘要: 题意:有一个含有n辆车的车队,当前距离终点的距离已知,有m个加速器,每个加速器在一个时刻只能给一辆车用,一旦使用就会使得其速度由1变成k,加速器可以重复使用,问最快所有车辆到达终点的时间。题解:二分答案,通过在这个时间内加速器能够使用的个数来进行判断。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=100005; 6 int a[N],n,m,k; 7 bool check(int ti) 8 阅读全文
posted @ 2012-10-17 15:26 tmeteorj 阅读(195) 评论(0) 推荐(0)
 
POJ 2872
摘要: 题意:给一个字典和一封邮件,判断是否邮件中的每个单词都出现在字典中。题解:裸字符串hash,勤快点的用C++手写hash,嫌麻烦就直接java吧View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char hash[1000007][60]; 6 const int mod=1000007; 7 int fac[60]; 8 int getkey(char s[]) 9 {10 int sum=0,i;11 for(i= 阅读全文
posted @ 2012-10-17 14:58 tmeteorj 阅读(169) 评论(0) 推荐(0)
 
POJ 3682
摘要: 题意:一场宴会,将会一直举办直到硬币投出第k次正面向上,正面向上的概率为p。另外,第i天的宴会将会花费2i-1的钱,问最后宴会结束期望以及花钱期望。题解:递推求期望,设dp1[i]为已经抛出i次正面时,结束时间的期望,dp2[i]为已经抛出i次正面时,结束金钱的期望。dp1[i]=(dp1[i]+1)*(1-p)+dp1[i+1]*p ==> dp1[i]=dp[i+1]+1/p假设宴会会矩形m天,第一天花费1,第二天花费3.......等价于第m天花费1,第m-1天花费3......所以,有了dp1,dp2[i]=(dp2[i+1]+(dp1[i+1]+1)*2-1)*p+(dp2[i 阅读全文
posted @ 2012-10-17 14:25 tmeteorj 阅读(316) 评论(0) 推荐(0)
 
POJ 2956
摘要: 题意:求第n个各位不重复的数。题解:以1,2...9作为初始结点,bfs依次从0到9加入其它的数,条件是这个数未在结点中出现过。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct data 6 { 7 int v,s; 8 data(){} 9 data(int _v,int _s){v=_v,s=_s;}10 }po[1001000];11 int main()12 {13 int f,r;14 f... 阅读全文
posted @ 2012-10-17 12:42 tmeteorj 阅读(461) 评论(0) 推荐(0)
 
POJ 1283
摘要: 题意:实际上就是将n拆分成m个数,不计顺序,且不允许为空,求总数。题解:dp[i][j]代表将j分成i份的种数(i>j时为0),那么dp[i][j]=dp[i-1][j-1]+dp[i][j-i],即分为两类,一类必须含有1,一类不含1。View Code 1 import java.math.*; 2 import java.util.Scanner; 3 class Main{ 4 static BigInteger dp[][]=new BigInteger[205][205]; 5 public static void main(String[] args) { 6 ... 阅读全文
posted @ 2012-10-17 12:24 tmeteorj 阅读(190) 评论(0) 推荐(0)
 
POJ 3365
摘要: 题意:给出一个w*h的矩形纸,将它剪成一个无盖圆柱,使圆柱体积最大。题解:数学推公式类型题。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 using namespace std; 6 const double pi=acos(-1.0); 7 int main() 8 { 9 double w,h,x,v1,v2;10 while(scanf("%lf%lf",&w,&h),w 阅读全文
posted @ 2012-10-17 11:32 tmeteorj 阅读(224) 评论(0) 推荐(0)
 
POJ 3345
摘要: 题意:一个国家想贿赂至少m个国家,给出贿赂每个国家需要的钱及他们的附属关系。如果贿赂了主国,其从属国家也同样视为被贿赂了,且关系网无环。题解:树形DP,dp[now][i]为以第now国家为子树的国家团体贿赂了i个国家所需要的最小花费,在建立一个虚拟结点0,让它与所有主国建立一条边。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<map> 5 #include<string> 6 using namespace std; 阅读全文
posted @ 2012-10-17 11:31 tmeteorj 阅读(437) 评论(0) 推荐(0)
 
 

公告


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