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

POJ 2666
摘要: 题意:海上有地方发生爆炸,一个人与主船脱离,他想回到主船上去。爆炸的冲击波会使得主船沿着爆炸点到它的方向以V的速度远离,人有种装置确定主船位置,但是必须保证他到爆炸点的距离与船到爆炸点的距离一样,人的速度为2V,当前他们距离爆炸点的距离为D,人与船对于爆炸点的夹角为Θ,求人回到船的时间,如果大于10000,就输出"God help me!"。题解:为了保证人和船时时刻刻与爆炸点距离相等,所以人的径向速度也应为V,那么切向速度就是√3V,在t时刻,他到爆炸点的距离为D+tV,于是在dt时间内,他旋转的角速度就是(√3V)/(D+tV),角度为(√3V)/(D+tV)*dt=d 阅读全文
posted @ 2012-10-02 20:28 tmeteorj 阅读(163) 评论(0) 推荐(0)
 
POJ 3181
摘要: 题意:给出n和m,求[1,m]的数中有多少种的和是n题解:解法不是重点,就是一个简单的背包问题,dp[j+i]+=dp[j],1<=i<=m。问题是n<=1000,m<=100,超long long了,所以java BigInteger一水OK。View Code 1 import java.math.*; 2 import java.util.Arrays; 3 import java.util.Scanner; 4 class Main{ 5 static BigInteger dp[]=new BigInteger[1005]; 6 public static v 阅读全文
posted @ 2012-10-02 19:21 tmeteorj 阅读(250) 评论(0) 推荐(0)
 
POJ 2264
摘要: 题意:给出两个字符串,求新的长度最小的字符串,使得给出的两个字符串均是它的子序列。题解:要想最小,就是让两个字串合并起来时相同排列的尽可能合并成一个,即最长公共子序列。所以先求一遍最长公共子序列s,同时记录串s第i位分别是给出的两个字符串s1和s2的哪一位,如果对于s的第k位,对应于s1串的第i位,那么位于s1串i位之前未写进答案串的所有字符均应当在s[k]之前写进去,s2同理可得。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace 阅读全文
posted @ 2012-10-02 18:57 tmeteorj 阅读(232) 评论(0) 推荐(0)
 
POJ 2191
摘要: 题意:判断所有质数i<=k,2^i-1是否是质数,不是的话就要将它分解质因数输出来。题解:miller_rabin判,pollard-pho分解,基本就是枚举,也可以打表。View Code 1 #include<ctime> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<algorithm> 6 using namespace std; 7 long long factor[100],fac_top = -1; 8 //计算两个数的g 阅读全文
posted @ 2012-10-02 16:53 tmeteorj 阅读(739) 评论(0) 推荐(0)
 
POJ 2649
摘要: 题意:判断m能否整除n!题解:0特判,其他情况对m分解质因数并统计个数,看n!是否含多余该个数的质因数,n!关于质因数p的个数=(n/p+n/p^2+n/p^3......),即求出mod p=0,mod p^2=0等的个数。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cmath> 5 using namespace std; 6 const int mr=65536; 7 bool notp[mr]; 8 int pr[mr] 阅读全文
posted @ 2012-10-02 16:07 tmeteorj 阅读(288) 评论(0) 推荐(0)
 
POJ 1944
摘要: 题意:n个点的环,只能邻接点建边,现在要求m对点相连,求最小边。题解:最后必定是生成的一些链,否则可以把环打开少用一条边。那么可以枚举这个断点在哪,计算取最小值。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<queue> 5 using namespace std; 6 const int N=1005; 7 int to[N],po[10005][2],n,m; 8 int main() 9 {10 while(scanf(&q 阅读全文
posted @ 2012-10-02 15:18 tmeteorj 阅读(393) 评论(0) 推荐(0)
 
POJ 3978
摘要: 题意:求区间[a,b]内所含质数个数。题解:筛一遍素数,二分查找。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int mr=100001; 6 bool notp[mr]; 7 int pr[mr]; 8 int pn; 9 void getpri()//筛素数10 {11 memset(notp,0,sizeof(notp));12 for(int i=2; i<mr; i++)13 {14 阅读全文
posted @ 2012-10-02 13:28 tmeteorj 阅读(185) 评论(0) 推荐(0)
 
POJ 3640
摘要: 题意:n个学生的5门课程,找出课程组合出现次数最多的,输出选出现次数最多课程组合(不一定一个)的学生人数。题解:对5门课程排序,然后hash判重,接着统计即可。View Code 1 #include<cstring> 2 #include<algorithm> 3 #include<string> 4 #include<map> 5 #include<cstdio> 6 using namespace std; 7 const int mod=1000000; 8 long long hash[mod]; 9 int tot[mod 阅读全文
posted @ 2012-10-02 13:13 tmeteorj 阅读(316) 评论(0) 推荐(0)
 
POJ 3332
摘要: 题意:检查输入字符串是否是浮点型。题解:模拟= =!View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cctype> 5 using namespace std; 6 int main() 7 { 8 int T; 9 for(scanf("%d",&T); T; T--)10 {11 char s[1200];12 scanf(" %s",s);13 if(s[0]=='+&# 阅读全文
posted @ 2012-10-02 12:37 tmeteorj 阅读(256) 评论(0) 推荐(0)
 
POJ 1406
摘要: 题意:给定n,确定x*x*x+y*(y+1)*(y+2)/6使得不超过n且最接近n题解:n才十多万,直接打表。View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 const int N=160000; 6 bool mark[160000]; 7 int main() 8 { 9 memset(mark,false,sizeof(mark));10 for(int x=0;;x++)11 {12 int t=x*x... 阅读全文
posted @ 2012-10-02 12:17 tmeteorj 阅读(208) 评论(0) 推荐(0)
 
POJ 2193
摘要: 题意:一个长度为n的数列(a1,a2...an),满足a[n]<=m&&a[i]>=2*a[i-1],给你n,m,求满足要求数列个数。题解:dp[i][j]代表长度为i且a[i]=j的数列的种数,sp[i][j]代表长度为i且a[i]<=j的种数。dp[i][j]=sum(dp[i-1][k])(k<=j/2),sp[i][j]=sp[i][j-1]+dp[i][j];View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #in 阅读全文
posted @ 2012-10-02 11:19 tmeteorj 阅读(189) 评论(0) 推荐(0)
 
POJ 1143
摘要: 题意:两个人玩游戏,初始集合S为大于1的正整数集,轮流写出一个大于1的数然后将:“1、所有这个数的倍数;2、这个数的倍数与前面已经删去的数的和”从集合S中删去,现在告诉你S的现状,求所有必胜走法的第一步。题解:数的数量小于20,可以用位压缩dp,记录S中还剩哪些元素时是否是必胜态,然后通过记忆化搜索求出所有走第一步后是必败态的策略。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int dp[(1<<20 阅读全文
posted @ 2012-10-02 10:23 tmeteorj 阅读(628) 评论(0) 推荐(0)
 
 

公告


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