日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

    
        
    歡迎訪問 生活随笔!

    生活随笔

    當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

    编程问答

    牛客网多校第4场 D Another Distinct Values 【构造】

    發布時間:2025/4/9 编程问答 34 豆豆
    生活随笔 收集整理的這篇文章主要介紹了 牛客网多校第4场 D Another Distinct Values 【构造】 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

    題目:戳這里

    題意,n*n的矩陣,只能填-1,0,1,問能不能使該矩陣的任意行和列的和都不想等。

    解題思路:戳這里

    可以說是一目了然了

    ?

    附ac代碼:

    1 #include<iostream> 2 #include<algorithm> 3 #include<stdio.h> 4 #include<string.h> 5 #include<string> 6 #include <cmath> 7 using namespace std; 8 typedef long long ll; 9 const ll mod = 1e9 + 7; 10 const int maxn = 2e3 + 10; 11 int a[maxn][maxn]; 12 int main() 13 { 14 int t; 15 scanf("%d", &t); 16 int n; 17 while(t--) 18 { 19 memset(a, 0, sizeof(a)); 20 scanf("%d", &n); 21 if(n & 1) 22 { 23 puts("impossible"); 24 continue; 25 } 26 puts("possible"); 27 for(int i = 1; i <= n / 2; ++i) 28 { 29 for(int j = 1; j <= n - i + 1; ++j) 30 { 31 a[i][j] = 1; 32 } 33 } 34 for(int i = n / 2 + 1; i <= n; ++i) 35 { 36 for(int j = n; j > n - i + 1; --j) 37 { 38 a[i][j] = -1; 39 } 40 } 41 for(int i = 1; i <= n; ++i) 42 { 43 for(int j = 1; j <= n; ++j) 44 { 45 if(j > 1) printf(" "); 46 printf("%d", a[i][j]); 47 } 48 printf("\n"); 49 } 50 } 51 } View Code

    ?

    轉載于:https://www.cnblogs.com/zmin/p/9443455.html

    總結

    以上是生活随笔為你收集整理的牛客网多校第4场 D Another Distinct Values 【构造】的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。