原创 【華爲OJ】iNOC產品部--完全數計算

問題描述:完全數(Perfect number),又稱完美數或完備數,是一些特殊的自然數。它所有的真因子(即除了自身以外的約數)的和(即因子函數),恰好等於它本身。例如:28,它有約數1、2、4、7、14、28,除去它本身28外,其餘5個

原创 【華爲OJ】統計大寫字母個數

輸入:字符串 輸出:大寫字母的個數 #include<iostream> #include<string> using namespace std; int main() { string str; getline(cin,str)

原创 【華爲OJ】DNA序列

描述: 一個DNA序列由A/C/G/T四個字母的排列組合組成。G和C的比例(定義爲GC-Ratio)是序列中G和C兩個字母的總的出現次數除以總的字母

原创 【華爲OJ】表示數字

輸入:字符串 輸出:數字前後加* 如: 輸入:sfadf5678sdfm12w3o 輸出:sfadf*5678*sdfm*12*w*3* #include <iostream> using namespace std; int ma

原创 【華爲OJ】自守數

自守數是指一個數的平方的尾數等於該數自身的自然數。例如:25^2 = 625,76^2 = 5776,9376^2 = 87909376。請求出n以內的自守數的個數 輸入:N 輸出:N以內自守數的個數#include <iostream>

原创 【華爲OJ】超長正整數相加

輸入:兩個超長正整數  (string類型) 輸出:兩數之和 #include<iostream> #include<string> using namespace std; int main() { string str1,str

原创 【華爲OJ】記負均正

輸入:整數個數n  n個整數 輸出:整數中負數的個數 正整數的均數<pre name="code" class="cpp">#include <iostream> #include<iomanip> using namespace s

原创 【華爲OJ】放蘋果

將M個蘋果放在N個盤子裏,允許有空盤,但1,5,5和5,5,1視作一種方法 輸入:蘋果數   盤子數   輸出:一共可以排放的方法 #include <iostream> using namespace std; int cal

原创 【華爲OJ】百錢買百雞問題

<p>雞翁一值錢伍,雞母一值錢三,雞雛三值錢一。百錢買百雞,問雞翁、雞母、雞雛各幾何?</p><p>輸入:隨便輸入一個整數</p><p>輸出:雞翁、雞母、雞雛的數量</p> #include<iostream> using namesp

原创 【華爲OJ】輸出單向鏈表中倒數第k個結點

輸入:要輸出整數的個數  整數數組 k值 輸出:倒數第k個結點 說明:數組的最後一個數屬於倒數第0個數 #include<iostream> #include<vector> using namespace std; int mai

原创 【華爲OJ】查找組成偶數最接近的兩個素數

輸入:偶數 輸出:兩個和爲輸入值的最相近的兩個素數 #include<iostream> using namespace std; bool isprime(int num) { if (num == 2) return t

原创 【華爲OJ】整形數組合並

輸入:第一個數組個數 第一個數組數值 第二個數組個數 第二個數組數值 輸出:兩個數組合並(去掉重複數字)後升序輸出 #include<iostream> #include<map> using namespace std; int m

原创 【華爲OJ】公共字符字串計算

描述:計算兩個字符串的最大公共字串的長度,字符不區分大小寫 輸入:兩個字符串 輸出:最長公共子串的長度 例:輸入:asdfas werasdfaswe         輸出:6 #include<iostream> #include<al

原创 【華爲OJ】尼科徹斯定理

尼科徹斯定理:任何一個立方數都可以表示成底數個數的連續奇數之和 輸入:底數 輸出:連續奇數相加的字符串表達形式 #include<iostream> using namespace std; int main() { int n;

原创 【華爲OJ】iNOC產品部-楊輝三角的變形

描述             1         1  1  1      1  2  3  2  1   1  3  6  7  6  3  11  4  10 16 19  16 10  4  1以上三角形的數陣,第一行只有一個