UVA107等比数列注意特判
来源:互联网 发布:关闭数据还用流量 编辑:程序博客网 时间:2024/04/29 19:14
这题WA了一上午,最后找特判,想了好久竟然没有想到sc=1的特判情况,也是醉了,加了个特判分分钟AC了
#include<cstdio>#include<iostream>#include<vector>#include<queue>#include<algorithm>#include<string>#include<cstdlib>#include<map>#include<set>#include<cmath>#include<cstring>#include<cctype>#include<climits>#include<memory>#include<climits>using namespace std;#define LL long long#define INT (1<<31)-1const int maxn=1000;const double eps=1e-12;int dcmp(double x){ if(fabs(x)<eps) return 0; else return x>0?1:-1;}int main(){ int h,sc; while(cin>>h>>sc) { if(h==0&&sc==0) break; int nw=0,sh=0; int i,x; if(sc==1) { nw=log(h)/log(2); sh=2*h-1; } else { for(i=1;i<10000;i++) { if(h%(i+1)==0&&sc%i==0&&dcmp(log10(h)/log10(1+i)-log10(sc)/log10(i))==0) { break; } } nw=(sc-1)/(i-1); sh=h*(i+1)-sc*i; } cout<<nw<<' '<<sh<<endl; } return 0;}
0 0
- UVA107等比数列注意特判
- Minesweeper(暴力,注意特判)
- uva107
- POJ1040 递归搜索(取还是不取)+ 注意特判输入
- 特判方程迭代
- UVA LA 2218 列出不等式整理成半平面的形式来求半平面交,注意特判
- 艾呀喵啊 (特判与大数)
- HDOJ-1253(BFS + 特判)
- [POI 2011]Lollipop(二分+特判)
- UVA10596欧拉回路加特判
- 序列seq (各种特判)
- uva7511 Multiplication Table (模拟+特判)
- 玄学定理-Nan-Spj特判定理
- [BZOJ4542][HNOI2016]大数(莫队+特判)
- 等比数列
- 等比数列
- 等比数列
- 等比数列
- hdu 1299 Diophantus of Alexandria
- 筛选法求素数 打表
- UIView
- 【练习笔记】剑指offer-面试题3 :二维数组中的查找
- 线程间的通信(生产者与消费者)
- UVA107等比数列注意特判
- DRP问题系列——The Network Adapter could not establish the connection
- 新媒体“4U”理论
- 【NOIP2004】合唱队形题解
- checkBox多选支付列表的实现(可以跨屏幕实现多选并计算金额)
- Bundle savedInstanceState的作用
- 【Swift】学习笔记(七)——闭包
- Android开发中 ic_launcher 尺寸
- Model,gcc的__sync_synchronize要慎用。