题意

求第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]);
}

Kattis - triangle 【数学】的更多相关文章

  1. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  2. acdream.18.KIDx's Triangle(数学推导)

    KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Sub ...

  3. 杭赛.Triangle(数学推导)

    Triangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  4. CodeForces - 18A Triangle(数学?)

    传送门 题意: 给出三个点的坐标,初始,这三个点可以构成一个三角形. 如果初始坐标可以构成直角三角形,输出"RIGNT". 如果某个点的 x或y 坐标移动一个单位后可以组成直角三角 ...

  5. Codeforces Round #512 (Div. 2) D.Vasya and Triangle 数学

    题面 题意:给你n,m,k,在你在(0,0)到(n,m)的矩形内,选3个格点(x,y都是整数),使得三角形面积为n*m/k,不能找到则输出-1 题解:由毕克定理知道,格点多边形的面积必为1/2的整数倍 ...

  6. acdream.A Very Easy Triangle Counting Game(数学推导)

    A - A Very Easy Triangle Counting Game Time Limit:1000MS     Memory Limit:64000KB     64bit IO Forma ...

  7. Kattis - wheretolive 【数学--求质心】

    Kattis - wheretolive [数学] Description Moving to a new town can be difficult. Finding a good place to ...

  8. Kattis - amsterdamdistance【数学】

    Kattis - amsterdamdistance[数学] 题意 给出两个点 算出从第一个点到第二个点的最短距离,只不过这里不是直角坐标系, 是雷达图 思路 因为内圈的圆的路径要比外圈的小,所以我们 ...

  9. 数学 ACdream 1196 KIDx's Triangle

    题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...

随机推荐

  1. C#动态生成XML

    通过C#动态生成图书信息XML文件(Books.xml),文件如下: <?xml version="1.0" encoding="iso-8859-1"? ...

  2. Jenkins安装火线fireline插件

    原文请访问:http://magic.360.cn/zh/user.html 提示:如果您是第一次使用Jenkins,请先前往文章[Jenkins下载安装配置教程] 1. 点击左上角的`Jenkins ...

  3. 清除掉AD的相关属性!

    今天有朋友问我怎么清除掉AD 的相关属性,由于他们的用户都设置了登录到属性,这样我们的用户就仅仅能登陆他须要设置的计算机.对于兴许规则的变更的时候,我们的管理员配置起来就比較复杂.他须要非常长的时间去 ...

  4. sql语句偶记录

    查看表结构: show FULL COLUMNS FROM tablename;

  5. MyEclipse配置输出控制台信息至文本文件里

    有时会遇到这种情况.输出的信息过多,console控制台显示不全然.这是就须要将输出的信息输出到文本文件里,既能够查看也能够备份. 1.右击须要执行的项目->Run As->Run Con ...

  6. ISE封装IP

    1.综合成ngc文件,然后再黑盒调用,再写一个端口文件(写个空壳文件,就是定义输入输出,在工程里面调用这个文件就行,把ngc放到工程目录下).

  7. 细说Redirect重定向请求(情节分享)

         前些日子在开发公司项目接口的时候,由于需要与第三方平台对接,由于接口之前的层层封装,不断的需要转发,把人差点搞糊涂了.本来以为之前对Redirect的认识足够清楚,可是到实际开发之前我还是没 ...

  8. python在windows系统中打印中文乱码

    转自:http://www.111cn.net/phper/python/58920.htm 中文乱码对于程序开发人员来讲不是什么怪事情了,今天我在使用python打印中文时就出现乱码了,下面我们一起 ...

  9. ntp服务及其配置

    集群中使用NTP服务 简介 之前搭建zookeeper时报了一个错,我以为是ntp的问题,结果不是.这里详细学习一下如何在集群中使用ntp服务. 什么是ntp服务 来自ntp的百度百科: NTP服务器 ...

  10. getMeasuredHeight(),getScrollY(),getHeight()的区别和联系

    前言:关于控件的高度有两种获取方式,一个是获得控件的实际大小(getMeasuredHeight),就是包含显示部分和已显示的部分: 而getHeight是获得控件的显示的大小,如果控件大小超出的屏幕 ...