hiho一下第318周《小Hi与矩阵》题目分析

1 answer(s)

0

// suanfadima.cpp : 姝ゆ枃浠跺寘鍚?"main" 鍑芥暟銆傜▼搴忔墽琛屽皢鍦ㄦ澶勫紑濮嬪苟缁撴潫銆? //

include

include

using namespace std;

int main() { short n;//澶у皬涓簄*n鐨勭煩闃? short a[201][201];//鐭╅樀 cin >> n; for (short i = 1; i <= n; i++) for (short j = 1; j <= n; j++) cin >> a[i][j];//杈撳叆鐭╅樀鐨勫€? int Q;//璁块棶鐨勮鏁? int b[100000][3]; 緭鍏ュ潗鏍囧拰鏁撮櫎鐨勫€? cin >> Q; for (int i = 0; i < Q; i++) for (int j = 0; j < 3; j++) cin >> b[i][j];//杈撳叆鍧愭爣鍜屽€? int c = 0, d, r = 0; while (c < Q) { int x, y,k; x= b[c][0]; y= b[c][1]; k = b[c][2]; for (short i = 1; i <= n; i++) { for (short j = 1; j <= n; j++) { d = abs(i - x) + abs(j - y); if (d <= k && k % a[i][j] == 0) r++; } } cout << r << endl; r = 0; c++; } return 0; }

write answer 切换为英文 切换为中文


转发分享