D. Roman Digits
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 11, 55, 1010and 5050 respectively. The use of other roman digits is not allowed.

Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as the sum of digits in it.

For example, the number XXXV evaluates to 3535 and the number IXI — to 1212.

Pay attention to the difference to the traditional roman system — in our system any sequence of digits is valid, moreover the order of digits doesn't matter, for example IX means 1111, not 99.

One can notice that this system is ambiguous, and some numbers can be written in many different ways. Your goal is to determine how many distinct integers can be represented by exactly nn roman digits I, V, X, L.

Input

The only line of the input file contains a single integer nn (1≤n≤1091≤n≤109) — the number of roman digits to use.

Output

Output a single integer — the number of distinct integers which can be represented using nn roman digits exactly.

Examples
input

Copy
1
output

Copy
4
input

Copy
2
output

Copy
10
input

Copy
10
output

Copy
244
Note

In the first sample there are exactly 44 integers which can be represented — I, V, X and L.

In the second sample it is possible to represent integers 22 (II), 66 (VI), 1010 (VV), 1111 (XI), 1515 (XV), 2020 (XX), 5151 (IL), 5555 (VL), 6060 (XL) and 100100 (LL).

打表找规律

下面为打表程序

#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("DATA.txt","r",stdin)
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
const int maxn = 1e6 + ;
set<int>st;
int n,sum=;
int val[]={,,,};
void dfs(int x) {
if (x==n+){
st.insert(sum);
return ;
}
for (int i= ;i< ;i++){
sum+=val[i];
dfs(x+);
sum-=val[i];
}
}
int main() {
for (int i= ;i<= ;i++) {
n=i;
sum=;
st.clear();
dfs();
printf("%d ",st.size());
}
return ;
}
 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("DATA.txt","r",stdin)
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e5 + ;
int ans[]={,,,,,,,,,,,};
int main() {
LL n;
scanf("%lld",&n);
if (n<=) printf("%d\n",ans[n]);
else printf("%lld\n",+(n-)*);
return ;
}

Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目的更多相关文章

  1. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

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

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

  3. Codeforces Round #493 (Div. 2)

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

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

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

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

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

  8. Codeforces Round #532(Div. 2) A.Roman and Browser

    链接:https://codeforces.com/contest/1100/problem/A 题意: 给定n,k. 给定一串由正负1组成的数. 任选b,c = b + i*k(i为任意整数).将c ...

  9. Cutting Codeforces Round #493 (Div. 2)

    Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...

随机推荐

  1. TW实习日记:第11、12天

    这两天其实都在做一件事,项目组组长丢了个需求下来,要求完成一个百度地图api的页面.原本以为和之前写微信接口的类似,没想到这次问题这么多.并且在写代码的时候和组长交流不畅导致心情也很差,深刻的反思了一 ...

  2. 【转】跨平台移动端开发框架NativeScript 发布正式版本

    原文:http://news.cnblogs.com/n/520865/ Nativescript 项目地址:http://www.telerik.com/nativescript “一次编码,处处运 ...

  3. [Clr via C#读书笔记]Cp4类型基础

    Cp4类型基础 Object类型 Object是所有类型的基类,有Equals,GetHashCode,ToString,GetType四个公共方法,其中GetHashCode,ToString可以o ...

  4. c语言中反转字符串的函数strrev(), reverse()

    1.使用string.h中的strrev函数 #include<stdio.h> #include<string.h> int main() { char s[]=" ...

  5. 无法启动mysql服务 错误1067:进程意外中止

    这个错误在前些周遇到过,没有解决,直接粗暴的卸载重装了,自己用的是wampserver集成环境,重装的后果是mysql里面的一些已有的数据库就没有了,有点小悲剧,不过幸好都是一些测试用的数据库,后面直 ...

  6. ubuntu apache nginx 启动 关闭

    转载自:http://www.comflag.com/2011/05/01/apache-web.htm 电影<社交网络>中,facebook创始人马克.扎克失恋后入侵哈佛大学宿舍楼服务器 ...

  7. Qt代码覆盖率code coverage(VS版)

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Qt代码覆盖率code coverage(VS版)     本文地址:http://techi ...

  8. navicat for mysql 10.1.7 注册码

    NAVN-LNXG-XHHX-5NOO名:组织:注册码:均为NAVN-LNXG-XHHX-5NOO 下载地址:http://www.cr173.com/soft/38153.html

  9. MVP开发模式的理解

    1.MVP是什么 如果从层次关系来讲,MVP属于Presentation层的设计模式.对于一个UI模块来说,它的所有功能被分割为三个部分,分别通过Model.View和Presenter来承载.Mod ...

  10. 整理下本周工作中遇到的疑问;uid/euid/suid;docker镜像管理

    1.系统中的父子进程关系,以及docker是如何处理的这种父子进程关系,线上问题发现,子进程长时间得不到退出. 2.调用system系统调用发生了啥事情,发现大量的页表拷贝. 3.通过shell命令通 ...