51Nod - 1024 矩阵中不重复的元素(数学)
生活随笔
收集整理的這篇文章主要介紹了
51Nod - 1024 矩阵中不重复的元素(数学)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:點擊查看
題目大意:給出一個n*m的矩陣,再給出構造方法,輸出矩陣中有多少個互不相同的數字
題目分析:因為構造的方法涉及到冪次,且數據可能非常非常大,但是這個時候需要稍微想一下,我們需要的只是互不相同的數,所以我們可以對每個數都取一下log,然后用set暴力統計就好了
代碼:
#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; }?
總結
以上是生活随笔為你收集整理的51Nod - 1024 矩阵中不重复的元素(数学)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CodeForces - 548D Mi
- 下一篇: CodeForces - 1291D I