N - Roman Digits打表找规律

mac2024-06-05  46

传送门 思路:打表找规律,发现到12个数字以后,每两个数字相差49。 暴力出奇迹 每个a+b+c+d==i a * 1 + b *5 + c * 10 + d * 50

/** * From: * Qingdao Agricultural University * Created by XiangwangAcmer * Date : 2019-10-31-15.39.02 * Talk is cheap.Show me your code. */ #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<cstdlib> #include<queue> #include<cmath> #include<cctype> #include<stack> #include<map> #include<string> #include<cstdlib> #include<set> #define ll long long using namespace std; const ll maxn = 1e6 + 5; const ll minn = 1e9 + 5; const ll mod = 1000000007; const int INF = 0x3f3f3f3f; const long long LIMIT = 4294967295LL; vector<int>v[maxn]; int dp[maxn]; vector<int>G[maxn]; bool row[maxn], col[maxn]; bool flag = 0; queue<int>q; set<int>s; ll a[maxn]; int main() { ios::sync_with_stdio(false); for(int i = 1; i <= 20 ; i++) { for(int a = 0; a <= 20 ; a++) for(int b = 0; b <= 20;b++) for(int c = 0; c <= 20; c++) for(int d = 0; d <= 20; d++) { if(a + b + c + d == i) s.insert(a * 1 + b * 5 + c * 10 + d * 50); } cout << s.size() << endl; s.clear(); } return 0; } /** * From: * Qingdao Agricultural University * Created by XiangwangAcmer * Date : 2019-10-31-15.39.02 * Talk is cheap.Show me your code. */ #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<cstdlib> #include<queue> #include<cmath> #include<cctype> #include<stack> #include<map> #include<string> #include<cstdlib> #include<set> #define ll long long using namespace std; const ll maxn = 1e6 + 5; const ll minn = 1e9 + 5; const ll mod = 1000000007; const int INF = 0x3f3f3f3f; const long long LIMIT = 4294967295LL; vector<int>v[maxn]; int dp[maxn]; vector<int>G[maxn]; bool row[maxn], col[maxn]; bool flag = 0; queue<int>q; set<int>s; ll a[21] = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341, 390, 439, 488, 537, 586, 635, 684, 733}; int main() { ios::sync_with_stdio(false); ll n; cin >> n; if(n <= 20) cout << a[n] << endl; else cout << (n - 20) * 49 + 733 << endl; return 0; }
最新回复(0)