Constructing Tests CodeForces - 938C
大意: 定义m-free矩阵: 所有$m*m$的子矩阵至少有一个$0$的$01$矩阵.
定义一个函数$f(n,m)=n*n$的m-free矩阵最大$1$的个数.
给出$t$个询问, 每个询问给出$x$, 求输出$f(n,m)=x$的任意一组$(n,m)$.
显然可以得到$f(n,m)=n^2-\lfloor\frac{n}{m}\rfloor ^2$
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#include <unordered_map>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head const int N = 4e4+10;
int sqr(int x) {return x*x;}
int f(int x, int y) {
if (y>x||y<=0) return -1;
return sqr(x)-sqr(x/y);
} int main() {
int t;
scanf("%d", &t);
while (t--) {
int x;
scanf("%d", &x);
if (!x) {puts("1 1");continue;}
int n=0,m=0;
REP(i,1,N) if (i*i>x) {
int j = i/sqrt(i*i-x);
REP(k,j-10,j+10) if (f(i,k)==x) n=i,m=k;
}
if (n) printf("%d %d\n",n,m);
else puts("-1");
}
}
Constructing Tests CodeForces - 938C的更多相关文章
- Codeforces 938.C Constructing Tests
C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 938C - Constructing Tests
传送门:http://codeforces.com/contest/938/problem/C 给定两个正整数n,m(m≤n),对于一个n阶0-1方阵,其任意m阶子方阵中至少有一个元素“0”,则可以求 ...
- Educational Codeforces Round 38 (Rated for Div. 2) C
C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 38 (Rated for Div. 2)
这场打了小号 A. Word Correction time limit per test 1 second memory limit per test 256 megabytes input sta ...
- 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解
[比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B Run for your prize[贪心] ...
- Tree Constructing CodeForces - 1003E(构造)
题意: 就是让构造一个直径为d的树 每个结点的度数不能超过k 解析: 先构造出一条直径为d的树枝 然后去遍历这条树枝上的每个点 为每个点在不超过度数和直径的条件下添加子嗣即可 #include & ...
- 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration
题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...
- CodeForces - 1003-B-Binary String Constructing (规律+模拟)
You are given three integers aa, bb and xx. Your task is to construct a binary string ssof length n= ...
- Codeforces Round #642 (Div. 3) D. Constructing the Array (优先队列)
题意:有一个长度为\(n\)元素均为\(0\)的序列,进行\(n\)次操作构造出一个新序列\(a\):每次选择最长的连续为\(0\)的区间\([l,r]\),使得第\(i\)次操作时,\(a[\fra ...
随机推荐
- CLOB、BLOB , CLOB与BLOB的区别
CLOB 定义 数据库中的一种保存文件所使用的类型. Character Large Object SQL 类型 CLOB 在 JavaTM 编程语言中的映射关系.SQL CLOB 是内置类型,它将字 ...
- spark streaming 5: InputDStream
InputDStream的继承关系.他们都是使用InputDStream这个抽象类的接口进行操作的.特别注意ReceiverInputDStream这个类,大部分时候我们使用的是它作为扩展的基类,因为 ...
- WebStrom编程小技巧--HTML快速创建指定id或者类名的div
打印div标签快速方法:“先打出#yz,然后Tab键补全即可获得<div id="yz"></div>同理:我们也可以先打出“.tz"然后Tab键 ...
- tensorflow读取图片案例
1.知识点 """ 1.图片读取流程与API: 1.构造图片文件队列 文件队列API: a)tf.train.string_input_producer(string_t ...
- C基础知识(14):命令行参数
命令行参数是使用main()函数参数来处理的,其中,argc是指传入参数的个数,argv[]是一个指针数组,指向传递给程序的每个参数. 应当指出的是,argv[0]存储程序的名称,argv[1]是一个 ...
- 【转】HBASE Region in Transition issue on Master UI
[From]https://community.hortonworks.com/content/supportkb/244808/hbase-region-in-transition-issue-on ...
- appium+python等待方式使用
背景: 首先,由于一个网速和手机性能以及服务器反应时间等等的原因,不可能导致我们点击了某一个元素之后,它所要链接的页面马上弹出来可以进行下一步操作.所以我们需要一种等待方式,直至链接的页面跳出来之后再 ...
- ubuntu安装dockers和images:dvwa
docker安装 安装前需要更新系统 apt-get update apt-get upgrade apt-get install docker.io 安装完之后就可以试下: docker docke ...
- 问题 1014: [编程入门]阶乘求和python):(本地测试正确;但提交不对!!??)求教
问题 1014: [编程入门]阶乘求和 时间限制: 1Sec 内存限制: 128MB 提交: 27629 解决: 5450 题目描述 求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数 ...
- CDC类介绍
CDC类 中文介绍 CDC类定义的是设备上下文对象的类. CDC对象提供处理显示器或打印机等设备上下文的成员函数,以及处理与窗口客户区对应的显示上下文的成员. 通过CDC对象的成员函数进行所有的绘图. ...