[POJ 1289] The Cat in the Hat · 数学
来源:互联网 发布:js解析xml文件的作用 编辑:程序博客网 时间:2024/05/21 12:40
大概就是给你两个数A和B,有且仅有一组n,k满足:
然后输出 和
暴力枚举k即可。
#include <stdio.h>#include <algorithm>#include <iostream>#include <cmath>using namespace std;#define ll long longll A,B,n,k,sq,x,y,ans1,ans2;ll sqr( ll t , ll k ) {ll p = 1 ;while ( k -- ) p *= t ;return p ;}int main() {cin >> A >> B ;while ( 1 ) {if ( A + B == 0 ) break ;if ( B == 1 ){cout << "0 " << A << endl ;cin >> A >> B ;continue ;}for (ll i = 1 ; i <= 31 ; i++ ) {double h1,h2 ;h1 = pow( A , (double) 1 / (double) i ) - 1 ; h2 = pow( B , (double) 1 / (double) i ) ; if ( fabs( h1 - h2) < 1e-14 ) { n = (ll) ( h1 + 0.5 ) ; k = i ; break ; }}ans1 = sqr( n , k ) / ( n - 1 ) ;ans2 = 0 ;for (ll i = 0 ; i <= k ; i ++ ) ans2 += sqr( n + 1 , k - i ) * sqr( n , i ) ;cout << ans1 << " " << ans2 << endl ;cin >> A >> B ;}return 0;}
0 0
- [POJ 1289] The Cat in the Hat · 数学
- poj 1289 The Cat in the Hat
- POJ 1289 The Cat in the Hat 笔记
- UVa 107 The Cat in the Hat (数学)
- UVA 107 (暑假-数学 -E - The Cat in the Hat)
- uva 107 The Cat in the Hat(数学)
- The Cat in the Hat
- The Cat in the Hat
- The Cat in the Hat
- The Cat in the Hat
- The Cat in the Hat
- The Cat in the Hat
- The Cat in the Hat
- poj1289 The Cat in the Hat
- uva 107 The Cat in the Hat
- uva 107 the cat in the hat
- uva 107 - The Cat in the Hat
- UVa 107 - The Cat in the Hat
- Web端服务器推送技术原理分析及dwr框架简单的使用
- 【ThinkingInJava】55、对set中的操作测试性能比较
- 【ThinkingInJava】56、查询出文件路径下所有的文件
- 带自定义title的tabhost
- 【ThinkingInJava】57、批量修改文件的名字
- [POJ 1289] The Cat in the Hat · 数学
- Rational Rose2007详细安装步骤
- ubuntu下,wine完全卸载的方法.
- 自说自话:一些产品测试经验
- initialize github repo
- Scoket通信用ObjectOutputStream自动开箱时报错java.lang.ClassNotFoundException: org.cust.p2pClient.vo.ClientInfo
- Android设置全屏两种方式
- 【数据结构复习】线性表的链式存储--单链表
- JavaScript DOM操作