Codeforces 417E
#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的更多相关文章
- Codeforces 417E Square Table(随机算法)
题目链接:Codeforces 417E Square Table 题目大意:给出n和m.要求给出一个矩阵,要求每一列每一行的元素的平方总和是一个平方数. 解题思路:构造.依照 a a a b a a ...
- CodeForces - 417E(随机数)
Square Table Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- Python学习(14)模块一
目录 Python 模块 import语句 from ... import 语句 from ... import * 语句 定位模块 PYTHONPATH变量 命名空间和变量 dir()函数. glo ...
- maven项目搭建
一.Maven简介 Maven是基于Java平台的项目构建(mvn clean install).依赖管理(中央仓库,Nexus)和项目信息管理的项目管理工具. Maven是基于项目对象模型(POM) ...
- (二)再议MII、RMII、GMII接口
概述: MII (Media Independent Interface(介质无关接口)或称为媒体独立接口,它是IEEE-802.3定义的以太网行业标准.它包括一个数据接口和一个MAC ...
- Android 摇一摇之双甩功能
Android 摇一摇之双甩功能 最近做一个摇一摇的功能 网上相关代码很多 但是这次的需求有点奇葩 要求是摇两次才生效 看起来好像很简单 但真正要做遇到的问题还是很多 时间限制 机型灵敏性 摇动的方式 ...
- Html_页面的高度宽度等
offsetTop 指元素距离上方或上层控件的位置,整型,单位像素. offsetLeft 指元素距离左方或上层控件的位置,整型,单位像素. offsetWidth 指元素控件自身的宽度,整型,单位像 ...
- OpenCV3编程入门笔记(5)重要章节小节及核心函数
- Global Alignment(全局比对)--从算法(Needleman-Wunsch)到python实现
很早就知道有全局比对和局部比对这两种比对方法,都是用到的动态规划的思想,知道一些罚分矩阵的概念,但一直都没有机会搞透彻,一些算法的细节也不太清楚,也没有亲手编程实现. 现在由于项目需求,需要手动写一个 ...
- unity入门笔记
我于2010年4月1日硕士毕业加入完美时空, 至今5年整.刚刚从一家公司的微端(就是端游技术+页游思想, 具体点就是c++开发, directX渲染, 资源采取所需才会下载)项目的前端主程职位离职, ...
- Shell基础:Shell和Mysql交互
通过命令行和Mysql交互 [root]#mysql -uroot -p123 -e "show databases" -e: execute: 执行数据库命令 通过脚本和数据 ...
- sh脚本异常:bad interpreter: No such file or directory
转:http://bluedest.iteye.com/blog/1674963 在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file o ...