#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
using namespace std; bool judge(int s)
{
int k = sqrt(s);
return k*k == s;
}
int main()
{
int n,m;
int a,b,c,d;
scanf("%d%d",&n,&m);
while (true)
{
a = rand()% + ;
b = rand()% + ;
c = rand()% + ;
d = rand()% + ;
if (judge(a*a*(m-) + b*b)
&&judge(a*a*(n-)+c*c)
&&judge(b*b*(n-)+d*d)
&&judge(c*c*(m-)+d*d))
break;
}
for (int i = ;i<n;i++)
{
for (int j = ;j<m;j++)
printf("%d ",a);
printf("%d\n",b);
}
for (int i = ;i<m;i++)
printf("%d ",c);
printf("%d\n",d);
return ;
}

代码

随机构造

Codeforces 417E的更多相关文章

  1. Codeforces 417E Square Table(随机算法)

    题目链接:Codeforces 417E Square Table 题目大意:给出n和m.要求给出一个矩阵,要求每一列每一行的元素的平方总和是一个平方数. 解题思路:构造.依照 a a a b a a ...

  2. CodeForces - 417E(随机数)

    Square Table Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. iOS - Swift Struct 结构体

    1.Struct 的创建 1.1 基本定义 结构体的定义 // 定义结构体数据类型 struct BookInfo { // 每个属性变量都必须初始化 var ID:Int = 0 var Name: ...

  2. JSON学习总结

    最近几天使用json的需求比较急迫,所以学习了一下json.此文仅当笔记,以防忘却. 此文主要分为js和java总结: 先介绍json格式: JSON 数据的书写格式是:名称/值对. ***:可以更容 ...

  3. JS自总结

    1.js获得当前元素   event.srcElement:   获取当前父元素   event.srcElement.parentElement   var rowIndex = e.parentE ...

  4. Debian8系统下,caffe的安装

    特此声明:本文不允许用于商业目的,允许转载(注明一下啦). 首先,官方的参考文献为:http://caffe.berkeleyvision.org/installation.html. 现在开始: 安 ...

  5. Map在内存中的结构

  6. shader学习路线

    http://www.jianshu.com/p/7b9498e58659 http://blog.csdn.net/candycat1992/article/details/37882765

  7. Linux下安装最新的Eclipse

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  8. object-c NSString 转成特定编码格式如utf8、gbk等

    有两种方式 第一种是先转换成特定编码格式NSDATA 第二种是先转换成特定编码格式char *(cString) 转成gbk: 第一种: - (NSString *) utf82gbk:(NSStri ...

  9. sql server多表数据批量更新

    update wset w.TagCount=x.TagCountfrom (select ItemID,COUNT(*) as TagCount from r where IsValid=1 gro ...

  10. Shell基础:Shell和Mysql交互

    通过命令行和Mysql交互 [root]#mysql -uroot -p123 -e "show databases"   -e: execute: 执行数据库命令 通过脚本和数据 ...