51 Nod 1024 Set

1024 矩阵中不重复的元素

 
一个m*n的矩阵。
 
该矩阵的第一列是a^b,(a+1)^b,.....(a + n - 1)^b
第二列是a^(b+1),(a+1)^(b+1),.....(a + n - 1)^(b+1)
.......
第m列是a^(b + m - 1),(a+1)^(b + m - 1),.....(a + n - 1)^(b + m - 1)
(a^b表示a的b次方)
 
下面是一个4*4的矩阵:
 
2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
5^2=25, 5^3=125, 5^4=625, 5^5=3125
 
问这个矩阵里有多少不重复的数(比如4^3 = 8^2,这样的话就有重复了)
 
2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
 
m = 4, n = 3, a = 2, b = 2。其中2^4与4^2是重复的元素。
 
 

输入

输入数据包括4个数:m,n,a,b。中间用空格分隔。m,n为矩阵的长和宽(2 <= m,n <= 100)。a,b为矩阵的第1个元素,a^b(2 <= a , b <= 100)。

输出

输出不重复元素的数量。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<time.h>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 20005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
#define mclr(x,a) memset((x),a,sizeof(x))
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-5
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

inline int rd() {
	int x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}


ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }



/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/

double A[102][102];
int  n, m;
int a, b;
set<double>st;

int main()
{
	//	ios::sync_with_stdio(0);
	m = rd(); n = rd();
	a = rd(); b = rd();
	int ans = 0;
	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) {
			A[i][j] = 1.0*b * log2(a + i - 1);
			st.insert(A[i][j]);
		}
		b++;
	}
	ans = st.size();
	printf("%d\n", ans);
	return 0;
}

 

posted @ 2019-02-28 08:59  NKDEWSM  阅读(123)  评论(0编辑  收藏  举报