【数学题】ZOJ 3205 Derivative

来源:互联网 发布:萧山问政网络官网 编辑:程序博客网 时间:2024/06/06 08:45

写程序过程中,各种小问题,真是令人揪心。。。

#include <stdio.h>#include <map>#include <math.h>#include <algorithm>#include <string>#include <string.h>#include <iostream>#define MAXN 110#define mm(a) memset(a, 0, sizeof(a))using namespace std;int pw[MAXN][MAXN];void creat(){for(int i=0;i<110;i++){pw[ 0 ][ i ] = 0;pw[ i ][ 0 ] = 1;}for(int i=1;i<110;i++){long long t=1;for(int j=1;j<110;j++){t*=i;if(t>=1000000007) t%=1000000007;pw[i][j]=t;}}}int main(){creat();int T;scanf("%d", &T);while(T--){int n, m;scanf("%d%d", &n, &m);int C[110],p[120][120];for(int i = 1; i <= n; i++){scanf("%d", &C[i]);for(int j = 1; j <= m; j++)scanf("%d", &p[i][j]);}int q;scanf("%d", &q);while(q--){int x[110];for(int i = 1; i <= m; i ++)scanf("%d", &x[i]);for(int i = 1; i <= m; i++){long long  ans = 0;for(int j = 1; j <= n; j++){if(p[j][i] == 0) continue;long long temp = 1;for(int k = 1; k <= m; k ++){if(k == i){temp *= p[j][i];if(temp >= 1000000007) temp %= 1000000007;temp *= pw[x[i]][p[j][i] - 1];if(temp >= 1000000007) temp %= 1000000007;}else{temp *= pw[x[k]][p[j][k]];if(temp >= 1000000007) temp %= 1000000007;}}temp *= C[j];if(temp >= 1000000007) temp %= 1000000007;ans += temp;if(ans >= 1000000007) ans %= 1000000007;}if(i != 1) printf(" ");printf("%d", ans);}printf("\n");}if(T)printf("\n");}return 0;}


0 0
原创粉丝点击