模擬。
#include usingnamespace
std;
intmain()
五重迴圈列舉或dfs均可。
#include usingnamespace
std;
string s = "
00000";
void dfs(int
dep)
s[dep] = '0'
; dfs(dep + 1
); s[dep] = '1'
; dfs(dep + 1);}
intmain()
觀察發現a的位置與所在行數相關,確定 $a$ 後向左右延伸出 $bcd\dots$ 即可。
當行數比列數大時,列舉a時會越界,可以先預設出足夠的空間。
#include usingnamespace
std;
const
int n = 30
;int
n, m;
vector
mp(n, string(n, '#'
));int
main()
return0;
}
模擬。
#include usingnamespace
std;
intmain()
模擬。
#include usingnamespace
std;
intmain()
模擬。
#include usingnamespace
std;
const
int n = 50
;int
main()
}for (int i = 1; i <= n; i++)
}return0;
}
模擬。
#include #define pow3(n) (n * n * n)using
namespace
std;
bool ok(int
n) int
main()
return0;
}
根據回文數的性質構造出前半部分即可,注意第一位不能為0。
#include usingnamespace
std;
intmain()
}return0;
}
同上。
#include usingnamespace
std;
intmain()
} }}
for (int i = 1; i <= 9; i++)
} }}
return0;
}
模擬。考慮到 $n = 0$ 的情況,用 do
while()
。
#include usingnamespace
std;
intmain()
while
(n);
reverse(s.begin(), s.end());
cout
<< s << "\n"
;
return0;
}
模擬。
#include usingnamespace
std;
long
long hex_to_dec(const
string &hex)
return
res;
}int
main()
模擬。
#include usingnamespace
std;
string hex_to_bin(const
string &hex)
while (bin[0] == '
0') bin.erase(0, 1
);
if (bin.size() % 3) bin = string(3 - bin.size() % 3, '
0') +bin;
return
bin;
}string bin_to_oct(const
string &bin)
return
oct;
}void
solve()
intmain()
模擬。
#include usingnamespace
std;
intmain()
藍橋杯 基礎練習
basic 1 閏年判斷 給定乙個年份,判斷這一年是不是閏年。當以下情況之一滿足時,這一年是閏年 年份是4的倍數而不是100的倍數 年份是400的倍數。include using namespace std intmain basic 2 01字串 對於長度為5位的乙個01串,每一位都可能是0或1,...
藍橋杯 基礎練習(2 21)
給出乙個包含n個整數的數列,問整數a在數列中的第一次出現是第幾個。第一行包含乙個整數n。第二行包含n個非負整數,為給定的數列,數列中的每個數都不大於10000。第三行包含乙個整數a,為待查詢的數。如果a在數列 現了,輸出它第一次出現的位置 位置從1開始編號 否則輸出 1。61 9 4 8 3 9 9...
藍橋杯練習 基礎練習 查詢整數
題目鏈結 問題描述 給出乙個包含n個整數的數列,問整數a在數列中的第一次出現是第幾個。輸入格式 第一行包含乙個整數n。第二行包含n個非負整數,為給定的數列,數列中的每個數都不大於10000。第三行包含乙個整數a,為待查詢的數。輸出格式 如果a在數列中出現了,輸出它第一次出現的位置 位置從1開始編號 ...