CF997B Roman Digits
思路:
不是很好想的數學題。
參考了https://blog.csdn.net/litble/article/details/80924306
實現:
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 while (cin >> n) 7 { 8 long long ans = 0; 9 for (int i = 0; i <= 8 && i <= n; i++) 10 {11 for (int j = 0; j <= (i == 0 ? 8 : 4) && i + j <= n; j++) 12 { 13 ans += n + 1 - i - j; 14 } 15 } 16 cout << ans << endl; 17 } 18 return 0; 19 }
CF997B Roman Digits
相關推薦
CF997B Roman Digits
dig digi ble strong std pan csdn out rom 思路: 不是很好想的數學題。 參考了https://blog.csdn.net/litble/article/details/80924306 實現: 1 #include<bits
CF997B Roman Digits-這很規律!
題目連結 我們在研究羅馬數字。羅馬數字只有4個字元,I,V,X,L分別代表1,5,10,100。一個羅馬數字的值為該數字包含的字元代表數字的和,而與字元的順序無關。例如XXXV=35,IXI=12. 現在求問一個長度為 nn 的羅馬數字可以有多少種不同的值。( n \le
Codeforces 997B Roman Digits【暴力】【枚舉】
printf https urn lse ans def can eight png 缺欠的是做題的思路,當看到這道題發現n是10^9級別,第一反應是得找到一個公式。但怎麽找沒想出來。 滿足i+j+k+p = n (i,j,k,p分別是1,5,10,50取的個數),我們可以
Roman Digits (暴力打表找規律)
題意:1,5,15,50四個數,可重複取不同的n個數組成一個代表的數思路:規模為1e9,打表找規律(3個for迴圈,輸出答案),或者logn,發現後面都是等差數列遞增。題目具有技巧性,但是也值得思考背後的原理與積累,希望一段時間後還能會過來看看思考這道題。程式碼:#inclu
CF 997B Roman Digits
傳送門 題目大意 思路 參考程式碼 總結 傳送門 題目大意 現在規定羅馬數字只有 44 個字元:I、V、X、L,分別代表 11、55、1010、5050。規定:一個羅馬數字的值為該數字包含的字元代表的數字之和,而
Roman Digits(CF-998D)
Problem Description Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the
D. Roman Digits【打表】
題意:有1,5,10,50四種數字,問用n個數字,能構成多少個不同的數字?思路:DFS打表觀察#include<bits/stdc++.h> #define PI acos(-1.0) #d
Codeforces Round #493 (Div. 2) D. Roman Digits
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 respecti
CodeForces ~ 998D ~ Roman Digits (打表找規律)
題意四個羅馬數字'I','V','X','L'分別表示1,5,10,50,問用這四個羅馬數字組成一個長度為n的串能夠表示多少個數字?“XI”和“IX”相等都表示的是11。題解當時沒做出來,後來補的。暴力
Roman Digits(打表找規律)
Roman Digits Let’s introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the
Codeforces 998D Roman Digits
題目:點選開啟連結題意:I=1, V=5, X=10, L=50,n個位置可任意放4個數,n個數組成的值是每一位的值的和,要求最後代表的值不同的種類數。分析:看起來沒有什麼特別的演算法能解決,只能暴力打
Codeforces 998D Roman Digits 暴力打表找規律
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 respecti
CF--998D. Roman Digits
題意:I=1, V=5, X=10, L=50,n個位置可任意放4個數,n個數組成的值是每一位的值的和,要求最後代表的值不同的種類數。 思路:一開始想錯了,想成了排列組合的四個數個數不完全相同的種
Codeforces Round #493 (Div. 2):D. Roman Digits
題意(轉換後):給你一個n,問在滿足x+y+a+b=n的情況下,x+5y+10a+50b有多少種不同的結果結論:當n≤11的時候直接暴力,n≥12滿足F(i)=F(i-1)+49思路:假設有這樣道題:你有1元,5元,10元,50元紙幣若干張,問你能組成多少種不同面值,你會發現
leetcode題解 || Roman to Integer問題
leet only top xiv har convert 擁有 pro think problem: Given a roman numeral, convert it to an integer. Input is guaranteed to be within
357. Count Numbers with Unique Digits
10個 pub col digi ota 要求 all 代碼 ould 題目: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Ex
[LintCode] Integer to Roman
new pre create ems ive starting lintcode mapping with Given an integer, convert it to a roman numeral. The number is guaranteed to be w
[LintCode] Roman to Integer
color small tee mean || cnblogs ash for hashmap Given a roman numeral, convert it to an integer. The answer is guaranteed to be within
LeetCode 13. Roman to Integer
cnblogs 如果 mes std line logs urn onclick += https://leetcode.com/problems/roman-to-integer/#/description Given a roman numeral, convert
LeetCode(12)Integer to Roman
題目 img code num mage roman div iii lee 題目如下: Python代碼 def intToRoman(self, num): """ :type num: int :rtype: str