51Nod - 1024 矩阵中不重复的元素(数学)
生活随笔
收集整理的這篇文章主要介紹了
51Nod - 1024 矩阵中不重复的元素(数学)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目鏈接:點(diǎn)擊查看
題目大意:給出一個(gè)n*m的矩陣,再給出構(gòu)造方法,輸出矩陣中有多少個(gè)互不相同的數(shù)字
題目分析:因?yàn)闃?gòu)造的方法涉及到冪次,且數(shù)據(jù)可能非常非常大,但是這個(gè)時(shí)候需要稍微想一下,我們需要的只是互不相同的數(shù),所以我們可以對(duì)每個(gè)數(shù)都取一下log,然后用set暴力統(tǒng)計(jì)就好了
代碼:
#include<iostream> #include<cstdio> #include<string> #include<ctime> #include<cmath> #include<cstring> #include<algorithm> #include<stack> #include<queue> #include<map> #include<set> #include<sstream> #include<unordered_map> using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const int N=1e4+100;set<double>st;int main() { // freopen("input.txt","r",stdin); // ios::sync_with_stdio(false);int n,m,a,b;scanf("%d%d%d%d",&m,&n,&a,&b);for(int i=a;i<a+n;i++)for(int j=b;j<b+m;j++)st.insert(j*log2(i));printf("%d\n",st.size());return 0; }?
總結(jié)
以上是生活随笔為你收集整理的51Nod - 1024 矩阵中不重复的元素(数学)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: CodeForces - 548D Mi
- 下一篇: CodeForces - 1291D I