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 命令笔记: iptables
配置虚拟机网卡 NAT 联网: iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j MASQUERADE iptables -A FROWARD - ...
- C语言 | 基础知识点笔记
函数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
- Url Scheme实现APP间通信、分享
代码地址如下:http://www.demodashi.com/demo/12748.html 简介: URL Scheme就是一个可以让app相互之间可以跳转的对外接口.通过给APP定义一个唯一的U ...
- iOS项目开发之Socket编程
有一段时间没有认真总结和写博客了 前段时间找工作.进入工作阶段.比较少静下来认真总结,现在静下心来总结一下最近的一些心得 前言 AsyncSocket介绍 AsyncSocket详解 AsyncSoc ...
- SQL的四种连接
SQL的四种连接-内连接.左外连接.右外连接.全连接 今天在看一个遗留系统的数据表的时候发现平时查找的视图是FULL OUT JOIN的,导致平时的数据记录要进行一些限制性处理,其实也可以设置视图 ...
- 编写批处理命令来执行JAVA文件
http://baobeituping.iteye.com/blog/802543 1. JAVA工程路径结构 Project ------lib ------src ------W ...
- leetcode isPalindrome (回文数判断)
回文很简单,就是正着读和反着读一样,要判断一个数是否为回文数只需要判断正反两个是不是相等即可. 再往深了想一下,只需要判断从中间分开的两个数一个正读,一个反读相等即可. 代码: class Solut ...
- python 用win32修改注册表,修改打开IE浏览器的配置
打开注册表:win+r, regedit,注册表的管理是按照文件夹的形式的. 注册表总共有五项: HKEY_CLASSES_ROOT 是HKEY_LOCAL_MACHINE\Software的子项,保 ...
- stage3D基础四----Stage3D和透视投影的使用(转)
原文地址: http://www.adobe.com/cn/devnet/flashplayer/articles/perspective-projection.html 引言 在本教程中,你将了解透 ...
- [译]GLUT教程 - 子菜单
Lighthouse3d.com >> GLUT Tutorial >> Pop-up Menus >> Sub Menus 上一节我们介绍了如何创建普通菜单和如果 ...