Kattis - triangle 【数学】
题意
求第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 【数学】的更多相关文章
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- acdream.18.KIDx's Triangle(数学推导)
KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Sub ...
- 杭赛.Triangle(数学推导)
Triangle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- CodeForces - 18A Triangle(数学?)
传送门 题意: 给出三个点的坐标,初始,这三个点可以构成一个三角形. 如果初始坐标可以构成直角三角形,输出"RIGNT". 如果某个点的 x或y 坐标移动一个单位后可以组成直角三角 ...
- 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的整数倍 ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- Kattis - wheretolive 【数学--求质心】
Kattis - wheretolive [数学] Description Moving to a new town can be difficult. Finding a good place to ...
- Kattis - amsterdamdistance【数学】
Kattis - amsterdamdistance[数学] 题意 给出两个点 算出从第一个点到第二个点的最短距离,只不过这里不是直角坐标系, 是雷达图 思路 因为内圈的圆的路径要比外圈的小,所以我们 ...
- 数学 ACdream 1196 KIDx's Triangle
题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...
随机推荐
- linux配置jdk失败
在linux下配置jdk时,/etc/profile下的配置内容是对的,可是输入java -version却发现配置没有成功,这一般都是jdk的安装文件夹权限没有提升的原因,仅仅需用chmod -R ...
- 通过mysql show processlist 命令检查mysql锁的方法
作者: 字体:[增加 减小] 类型:转载 时间:2010-03-07 show processlist 命令非常实用,有时候mysql经常跑到50%以上或更多,就需要用这个命令看哪个sql语句占用资源 ...
- Storm/Cassandra集成错误:NoSuchMethodError: concurrent.Futures.withFallback
本文原文出处: http://blog.csdn.net/bluishglc/article/details/50443205 严禁不论什么形式的转载.否则将托付CSDN官方维护权益. 2015年的最 ...
- [ Laravel 5.6 文档 ]laravel数据库操作分页(自定义分页实现和自定义分页样式)
简介 在其他框架中,分页可能是件非常痛苦的事,Laravel 让这件事变得简单.易于上手.Laravel 的分页器与查询构建器和 Eloquent ORM 集成在一起,并开箱提供方便的.易于使用的.基 ...
- 【Hadoop基础教程】1、Hadoop之服务器基础环境搭建(转)
本blog以K-Master服务器基础环境配置为例分别演示用户配置.sudo权限配置.网路配置.关闭防火墙.安装JDK工具等.用户需参照以下步骤完成KVMSlave1~KVMSlave3服务器的基础环 ...
- POJ1195 Mobile phones 【二维线段树】
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14291 Accepted: 6644 De ...
- Verilog利用$fdisplay命令往文件中写入数据
最近在做的事情是,用FPGA生成一些满足特定分布的序列.因此为了验证我生成的序列是否拥有预期的性质,我需要将生成的数据提取出来并且放到MATLAB中做数据分析. 但是网上的程序很乱,表示看不懂==其实 ...
- mybatis 单一参数时的动态语句
public void getBookList(String publisher,String author){ Map<String,Object> maps = new HashMap ...
- 2018年EI收录中文期刊目录【转】
[转]2018年EI收录中文期刊目录 Elsevier官网于2018年1月1日更新了EI Compendex目录,共收录中文期刊158种,其中新增期刊5种. 序号 中文刊名 收录情况 1 声学学报 保 ...
- 如何通过Git命令行把代码提交到github上
1.http://www.cnblogs.com/leesf456/p/5169765.html 参考博客 背景:最近入手了mac,看见mac上的大神都是在用git命令行推代码,我很羡慕有木有,好 ...