题意:
四个罗马数字'I','V','X','L'分别表示1,5,10,50,问用这四个罗马数字组成一个长度为n的串能够表示多少个数字?
“XI”和“IX”相等都表示的是11。
思路:
n辣么大估计有规律可破
那就打表吧
前14个的答案:
4 10 20 35 56 83 116 155 198 244 292 341 390 439
求相邻两个的差值:
6 10 15 21 27 33 39 43 46 48 49 49 49...后面都是49了
所以前11个打表 后11 为 (n-11)*49+a[11]
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <set>
#include <iostream>
#define ll long long
#define INF 0x3f3f3f
using namespace std;
const int N=1000000+100;
set<long long> s;
int a[18]={0,4,10,20,35,56,83,116,155,198,244,292,341,390,439};
int main()
{
int n;
scanf("%d",&n);
if(n<=11) printf("%d\n",a[n]);
else printf("%lld\n",(ll)(292+(ll)(n-11)*49));
return 0;
}