zoukankan      html  css  js  c++  java
  • Codeforces 417E

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<cmath>
     5 #include<cstdlib>
     6 using namespace std;
     7 
     8 bool judge(int s)
     9 {
    10     int k = sqrt(s);
    11     return k*k == s;
    12 }
    13 int main()
    14 {
    15     int n,m;
    16     int a,b,c,d;
    17     scanf("%d%d",&n,&m);
    18     while (true)
    19     {
    20         a = rand()%100 + 1;
    21         b = rand()%100 + 1;
    22         c = rand()%100 + 1;
    23         d = rand()%100 + 1;
    24         if (judge(a*a*(m-1) + b*b)
    25             &&judge(a*a*(n-1)+c*c)
    26             &&judge(b*b*(n-1)+d*d)
    27             &&judge(c*c*(m-1)+d*d))
    28             break;
    29     }
    30     for (int i = 1;i<n;i++)
    31     {
    32         for (int j = 1;j<m;j++)
    33         printf("%d ",a);
    34         printf("%d
    ",b);
    35     }
    36     for (int i = 1;i<m;i++)
    37     printf("%d ",c);
    38     printf("%d
    ",d);
    39     return 0;
    40 }
    代码

    随机构造

    爱程序 不爱bug 爱生活 不爱黑眼圈 我和你们一样 我和你们不一样 我不是凡客 我要做geek
  • 相关阅读:
    世纪末的星期
    马虎的算式
    蜜蜂飞舞
    Torry 的困惑
    级数调和
    数列
    最大最小公倍数
    蚂蚁感冒
    12.integer to Roman
    13.Roman to Integer
  • 原文地址:https://www.cnblogs.com/yifi/p/4849706.html
Copyright © 2011-2022 走看看