codeforces 997 B. Roman Digits(打表找规律)

http://codeforces.com/contest/997/problem/B
题意:有四种数字1,5,10,50 选x个数字,问和不同的有多少种

思路:看题目 没思路,打表找规律 (其实就是不会做,看看能不能猜结论)

打表发现n=11,结果为292 此后每项加49,直接暴力求出前面后面公式输出答案

#include<bits/stdc++.h>
#define fi first
#define se second
#define log2(a) log(n)/log(2)
#define show(a) cout<<a<<endl;
#define show2(a,b) cout<<a<<" "<<b<<endl;
#define show3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define tim printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
using namespace std;
 
typedef long long ll;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, ll> LP;
const ll inf = 1e9+100;
const int N = 1e6 + 10;
const ll mod = 1e9+7;
const int base = 131;
const double pi = acos ( -1 );
const double eps = 1e-8;
inline ll mul(ll x,ll y) { return (x*y-(ll)((long double)x*y/mod)*mod+mod)%mod;}
inline ll ksm(ll a,ll b) {ll ans=1;while(b){if(b&1)ans=mul(ans,a);a=mul(a,a),b>>=1;}return ans;}
 
#define a(i,j) a[(i-1)*m+(j)]
#define b(i,j) b[(i-1)*m+(j)]
 
unordered_map<ll, ll> mp;
 
 
ll n, m,x,y,z,cx,k;
ll ans;
ll a[N],b[N],c[N],vis[N],num[N];
set<ll> st;
P p[N];
ll sum,cnt,flag;
 
 
int main()
{
 
 
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	for(int x=1;x<=20;x++)
	{
		ans=0;
		for(int i=0;i<=10000;i++) vis[i]=0;
		for(int i=0;i<=x;i++)
			for(int j=0;j<=x;j++)
				for(int k=0;k<=x;k++)
					for(int z=0;z<=x;z++)
				{
					y=i+5*j+10*k+50*z;
					if(i+j+k+z==x&&!vis[y]) ans++,vis[y]=1;
 
				}
		num[x]=ans;
	}
	cin>>n;
	if(n<=11) cout<<num[n];
	else
	{
		cout<<292+(n-11)*49;
	}
 
 
 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值