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

2012年8月30日

POJ 2508
摘要: 直接将圆锥展开变成扇形,用比例算出夹角,再用余弦定理算出答案即可。#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const double eps=1e-8,PI=acos(-1.0);int main(){ double r,h,l,p1,p2,th1,th2,dt; while(scanf("%lf%lf%lf%lf%lf%lf",&r,&h,&p1,&th1,&am 阅读全文
posted @ 2012-08-30 13:20 tmeteorj 阅读(199) 评论(0) 推荐(0)
 
POJ 2431
摘要: d,p记录当前距离与总油量,初始化就是题目给的值,然后每次从能到达的点中选择一个油量最多的点与p相加,即现在p代表去该点加油后又乘时光机回到原来位置的总油量~结束条件为:1、没有可以到达加油站了。2、d<=p,即能到终点了。#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;struct data{ int dis,val; bool operator<(const data &next)const { r 阅读全文
posted @ 2012-08-30 12:52 tmeteorj 阅读(656) 评论(0) 推荐(0)
 
POJ 1985
摘要: 最长链,两遍heap+dijiska#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;const int N=40005;int head[N],nc;struct edge{ int to,cost,next;}edge[N*3];void add(int a,int b,int c){ edge[nc].to=b;edge[nc].next=head[a];edge[nc].cost=c;head[a]=nc++; ed 阅读全文
posted @ 2012-08-30 11:17 tmeteorj 阅读(304) 评论(0) 推荐(0)
 
 

2012年8月29日

POJ 3204
摘要: 求一次最小割,dfs一遍,然后对每一个满流且是正向边的做一次检查,如果这条边的终点能够到达汇点,则说明可以拓宽这条边来改进网络。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=1000,M=10000; 6 const int inff=1<<29; 7 int head[N],nc; 8 struct edge 9 { 10 int x,y,next; 11 int cap; 1 阅读全文
posted @ 2012-08-29 19:37 tmeteorj 阅读(201) 评论(0) 推荐(0)
 
POJ 2897
摘要: dfs搜索,实际上每次只有一个前进的方向,记录进位与当前位,用一个bool标记即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int n,k; 5 bool ok,g[10][10]; 6 void dfs(int res,int add) 7 { 8 if(res*n+add==k) 9 {10 ok=true;11 return;12 }13 else if(g[res][add])14 {15 ... 阅读全文
posted @ 2012-08-29 18:36 tmeteorj 阅读(174) 评论(0) 推荐(0)
 
POJ 2154
摘要: 由Polya定理可得到最后结果等于1/N*∑N^gcd(i,n);可是,N≤10^9,枚举i明显会超时,但gcd(i,n)最后得到的结果很少,最多1000多个,于是反过来枚举gcd(i,n)的值L,L即n的某个约数,那么我们需要找到0~n-1中有多少个数与n的约数是L,由扩展欧几里得可以知道,必然存在x,y使得i*x+n*y=L,由于L是i,n最大公约数,所以可以变成(i/L)*x+(n/L)*y=1,同时mod(n/L),(i/L)*x≡1(mod n/L),即,要找与n/L互质的i/L有多少个,变成欧拉函数了!于是,最后答案就变成了∑φ(n/L)*N^(L-1),dfs+快速幂取模搞定#i 阅读全文
posted @ 2012-08-29 17:23 tmeteorj 阅读(327) 评论(0) 推荐(0)
 
POJ 3286
摘要: 可以用数学方法去递归,也可以用DP。最后情况是:数学:30行代码,94MS;DP:69行代码,63MS;数学递归cpp:#include<cstring>#include<cstdio>using namespace std;void cac(long long con,long long &cnt,long long t){ if(con<=0) return; long long x,y,n=con/10; long long i,j; x=con/10,y=con%10; for(;x!=0;x/=10) if(x%10==0) cnt+=(y+1) 阅读全文
posted @ 2012-08-29 15:23 tmeteorj 阅读(327) 评论(0) 推荐(0)
 
POJ 2273
摘要: 算是进制转换吧#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){ char s[30]; while(gets(s)&&strcmp(s,"R0C0")!=0) { int m=0,i; for(i=1;s[i]!='C';i++); s[i]='\0'; for(++i;s[i]!='\0';i++) m=m*10+s[i]-'0'; char 阅读全文
posted @ 2012-08-29 12:46 tmeteorj 阅读(174) 评论(0) 推荐(0)
 
POJ 2038
摘要: 暴力+模拟=水#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int tot[50];int main(){ int n; while(scanf("%d",&n)&&n) { memset(tot,0,sizeof(tot)); char s[10]; for(int i=0;i<n;i++) { scanf("%s",s); for(int j=0;j<5;j++) ... 阅读全文
posted @ 2012-08-29 11:32 tmeteorj 阅读(269) 评论(0) 推荐(0)
 
 
上一页 1 ··· 17 18 19 20 21

公告


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