AtCoder Grand Contest 016(C - +/- Rectangle)
C - +/- Rectangle
题意:给定H,W,h,w四个数,求是否满足 全部数之和和正数,h行w列之和为负数。
1 #include <bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 int H, W, h, w; 5 6 int main(){ 7 cin >> H >> W >> h >> w; 8 if((H/h)*(W/w)*(1000*(h*w-1)+1)>1000*(H*w-(H/h)*(W/w))) 9 cout << "No\n"; 10 else{ 11 cout << "Yes\n"; 12 for(int i = 1; i <= H; i ++){ 13 for(int j = 1; j <= W; j ++){ 14 if(i%h==0&&j%w==0) 15 cout << -1000*(h*w-1)-1 << ' '; 16 else cout << 1000 << ' '; 17 } 18 cout << endl; 19 } 20 } 21 return 0; 22 }