zoukankan      html  css  js  c++  java
  • Kattis

    这里写图片描述

    这里写图片描述

    题意
    求第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
    ", count++, ans[n]);
    }
  • 相关阅读:
    关于PowerShell调用Linq的一组实验
    PowerShell创建参考窗口
    Python切图脚本
    11->8
    用Python演奏音乐
    关于Haskell计算斐波那契数列的思考
    傅立叶变换与小波分析
    堆排序(python实现)
    二进制数据表示方式
    oracle数据插入/查询乱码
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433244.html
Copyright © 2011-2022 走看看