CodeForces - 997B

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, 1010 and 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 (1n1091≤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
1
Output
4
Input
2
Output
10
Input
10
Output
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).

题意为,有4种数字,问用这四种数字能拼出多少个10位数来

而且这四种数字,不管位置,拼出的数字就是几种数字的加和,所以思路就是打表找规律

我估计这题描述有问题,输入的时候要用long long输入才行,用int输入一直错在第9组

思路是先暴力打标,然后找规律(千万不要手推)

 

打表程序

 1 /*
 2 加油,别忘记你写这段话时候的心情
 3 如临深渊,如履薄冰
 4 */
 5 #include<bits/stdc++.h>
 6 #include<cstdio>
 7 #include<cstring>
 8 #include<vector>
 9 #include<algorithm>
10 #include<cmath>
11 #include<iostream>
12 #include<queue>
13 #include<set>
14 using namespace std;
15 typedef long long ll;
16 typedef unsigned long long ull;
17 const int maxn = 300000+100;
18 const int maxn1=200000+1000;
19 
20 
21 int main()
22 {
23     set<int> s;
24     for(int z = 1; z <= 50; z++)
25     {
26         int t = s.size();
27         s.clear();
28         for(int i = 0; i <= z; i++)
29         {
30             for(int j = 0; j <= z-i; j++)
31             {
32                 for(int k = 0; k <= z-i-j; k++)
33                 {
34                     int l = z-i-j-k;
35                     s.insert(i+j*5+k*10+l*50);
36                 }
37             }
38         }
39         printf("%d %d\n",s.size(),s.size() - t);
40     }
41     return 0;
42 }

 

ac程序

 1 /*
 2 加油,别忘记你写这段话时候的心情
 3 如临深渊,如履薄冰
 4 */
 5 #include<bits/stdc++.h>
 6 #include<cstdio>
 7 #include<cstring>
 8 #include<vector>
 9 #include<algorithm>
10 #include<cmath>
11 #include<iostream>
12 #include<queue>
13 #include<set>
14 using namespace std;
15 typedef long long ll;
16 typedef unsigned long long ull;
17 const int maxn = 300000+100;
18 const int maxn1=200000+1000;
19 
20 ll a[100] = {0,4,10,20,35,56,83,116,155,198,244,292,341};
21 
22 int main()
23 {
24     ll n;
25     scanf("%lld",&n);
26     //printf("%d\n",n);
27     if(n <= 12)
28     {
29         printf("%lld\n",a[n]);
30     }
31     else
32     {
33         ll ans = a[12]+(n-12)*49;
34         printf("%lld\n",ans);
35     }
36     return 0;
37 }

 

转载于:https://www.cnblogs.com/wxytxdy/p/10664100.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值