题意

求第N个迭代三角形 中 所有黑色三角形的周长的整数部分的位数

思路

该三角形的周长是

3^(n + 1)/ 2 ^ (n)

然后 可以用 long double 存下来

再求位数 就可以

AC 代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll; const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6; const int INF = 0x3f3f3f3f;
const int maxn = 1e4 + 5;
const int MOD = 1e9 + 7; ld arr[maxn];
int ans[maxn]; int f(ld x)
{
int ans = 0;
while (x >= 1)
{
x /= 10;
ans++;
}
return ans;
} int main()
{
arr[0] = 3;
ans[0] = 1;
for (int i = 1; i <= 10000; i++)
{
arr[i] = arr[i - 1] * (3.0 / 2);
ans[i] = f(arr[i]);
}
int n;
int count = 1;
while (~scanf("%d", &n))
printf("Case %d: %d\n", count++, ans[n]);
}

最新文章

  1. 【代码笔记】iOS-中国地图
  2. spring入门教程——笔记
  3. 如何创建 CSS
  4. JavaScript常用事件
  5. hdu 4715 Difference Between Primes
  6. Jalopy 之 HelloWorld —— Jalopy 在 MyEclipse 下的安装与使用
  7. debian清除无用的库文件(清理系统,洁癖专用)
  8. LNK1123: 转换到 COFF 期间失败: 文件无效或损坏[汇总]
  9. Ubuntu 创建快捷方式的方法
  10. 数据结构(LCT动态树):BZOJ 1036: [ZJOI2008]树的统计Count
  11. linux搭建邮件服务器
  12. [Unity 3D] Unity 3D 里的碰撞检测
  13. 像屎一样的 Spring Boot入门,总算有反应了
  14. php 查询mysql数据批量转为PDF文件二(批量使用wkhtmltopdf html导出PDF)
  15. parallel方法 异步并行执行
  16. Java中this和super关键字
  17. leecode第四题(寻找两个有序数组的中位数)
  18. AN2820 Driving bipolar stepper motors using a medium-density STM32F103xx microcontroller
  19. 自己写的一个jQuery分页插件
  20. python 乘法表、打印菱形

热门文章

  1. Websphere: Stop Server and Uninstall Application
  2. 如何创建JAR文件?如何运行.jar形式的Java程序?
  3. sql server 类oracle vm_contact() 函数创建
  4. FishiGUI系统架构分析 和层次结构 二
  5. windows 配置squid反向代理服务器
  6. list集合转换成json类型
  7. SD--怎样增强是同一类出库单使用不同号码段
  8. csv文件中出现乱码的解决方法
  9. oracle复合索引的选择和使用
  10. 卸载Linux自带openjdk