题意:

我们在研究罗马数字。罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100。一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关。例如XXXV=35,IXI=12.

现在求问一个长度为 nnn 的罗马数字可以有多少种不同的值。

n&lt;=109n&lt;=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 打表找规律的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  4. Codeforces Round #493 (Div. 2)

    C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1  要么把所有的 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. ELO kernels 记录

    these kernel for discuss how to handle outliers in target values. 一:Ashish Gupta: 在16年6月到18年8月,激活卡的人 ...

  2. Hive sql

    1.DDL操作 1.1 建表 CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name [(col_name data_type [COMMENT col_ ...

  3. 【codeforces 724E】Goods transportation

    [题目链接]:http://codeforces.com/problemset/problem/724/E [题意] 有n个城市; 这个些城市每个城市有pi单位的物品; 然后已知每个城市能卖掉si单位 ...

  4. HDU 3698 Let the light guide us

    Let the light guide us Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on HDU. ...

  5. TensorFlow CNN 测试CIFAR-10数据集

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50738311 1 CIFAR-10 数 ...

  6. BIRT报表Cannot open the connection for the driver:org.eclipse.birt.report.data.oda.jdbc.dbprofile

    现象:报表不能打开: 找了半个小时,随手改了一下tomcat/conf文件夹下的context.xml文件 <Context xmlBlockExternal="false" ...

  7. hdu 4037 Development Value(线段树维护数学公式)

    Development Value Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others ...

  8. .NET 图片解密为BASE64

    #region 图片加密 /// <summary> /// 加密本地文件 /// </summary> /// <param name="inputname& ...

  9. sql不显示反复列

    在报表里,基本上都能够把反复的资料不显示,在SQL里怎么才干做到例如以下情况呢? a 10 a 20 b 30 b 40 b 50 显示为: a 10 20 b 30 40 50 SQL 例如以下: ...

  10. USACO 1.4 Arithmetic Progressions

    Arithmetic Progressions An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb ...