Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律
题意:
我们在研究罗马数字。罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100。一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关。例如XXXV=35,IXI=12.
现在求问一个长度为 nnn 的罗马数字可以有多少种不同的值。
n<=109n<=10^9n<=109.
题解:
我们可以用暴力的方法求出前20项的值,其中前111111 项采用打表的方式,而从第12项开始答案始终 = 前一项的答案 + 49,即 292+(n−11)∗49292+(n-11)*49292+(n−11)∗49
Code:
#include <cstdio>
#include<iostream>
using namespace std;
long long a[]={0,4,10,20,35,56,83,116,155,198,244,292};
int main(){
long long n;
scanf("%I64d",&n);
if(n <= 11) printf("%d",a[n]);
else
printf("%I64d",292+(n-11)*49);
return 0;
}
Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律的更多相关文章
- Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目
D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #260 (Div. 2) A , B , C 标记,找规律 , dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...
- Codeforces Round #493 (Div. 2)
C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1 要么把所有的 ...
- Codeforces Round #493 (Div 2) (A~E)
目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) C ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(如压力dp)
Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard i ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers 状压dp+数位dp
题目链接: http://codeforces.com/problemset/problem/401/D D. Roman and Numbers time limit per test4 secon ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)
D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...
- Codeforces Round #589 (Div. 2) A. Distinct Digits
链接: https://codeforces.com/contest/1228/problem/A 题意: You have two integers l and r. Find an integer ...
随机推荐
- php 的多进程
php的多进程处理依赖于pcntl扩展,通过pcntl_fork创建子进程来进行并行处理 例子1: <?php $pid = pcntl_fork(); if($pid == -1) { //错 ...
- centos7编译安装mysql5.6
先安装如下依赖包: $ yum -y install make gcc-c++ cmake bison-devel ncurses-devel 下载MySQL5.6.14安装包,https://pa ...
- C++基础 (3) 第三天 构造函数 构造函数初始化列表 拷贝构造函数 析构函数 静态成员变量
// 同类之间无私处 2构造函数 3析构函数 4构造函数的种类和析构函数的顺序 结论:析构函数的调用顺序,跟对象的构造顺序相反,谁先构造,谁最后一个被析构. 拷贝构造函数: 注意: 等号写在下面和写在 ...
- ASP 读取Word文档内容简单示例
以下通过Word.Application对象来读取Doc文档内容并显示示例. 下面进行注册Word组件:1.将以下代码存档命名为:AxWord.wsc XML code复制代码 <?xml ve ...
- PART 5: INTEGRATING SPRING SECURITY WITH SPRING BOOT WEB
转自:http://justinrodenbostel.com/2014/05/30/part-5-integrating-spring-security-with-spring-boot-web/ ...
- Docker:分布式系统的软件工程革命(上)
转自:http://cxwangyi.github.io/story/docker_revolution_1.md.html Docker:分布式系统的软件工程革命(上) 作者:王益 最后更新:201 ...
- WEBGL学习【五】纹理贴图
<html lang="zh-CN"> <!--服务器运行地址:http://127.0.0.1:8080/webgl/LearnNeHeWebGL/NeHeWe ...
- php 常用header
//定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/at ...
- Ubuntu18.04 安装 oh-my-zsh
目录 Ubuntu18.04 安装 oh-my-zsh 目录 安装zsh 安装curl 安装oh-my-zsh 使用zsh替换bash 修改终端主题和配色 修改终端配置 隐藏用户和主机名 效果图 Ub ...
- Ajax json jquery实现菜单案例
需求: 运用AJAX请求文件menu.json,配置菜单栏,并实现以下功能点: 1. 点击向左箭头,菜单向左移动,隐藏 2. 点击向右箭头,菜单向右移动,显示3. 点击一级菜单,被点击菜单的子菜单显示 ...