大意: 定义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的更多相关文章

  1. Codeforces 938.C Constructing Tests

    C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. Codeforces 938C - Constructing Tests

    传送门:http://codeforces.com/contest/938/problem/C 给定两个正整数n,m(m≤n),对于一个n阶0-1方阵,其任意m阶子方阵中至少有一个元素“0”,则可以求 ...

  3. 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 ...

  4. 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 ...

  5. 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解

    [比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B  Run for your prize[贪心] ...

  6. Tree Constructing CodeForces - 1003E(构造)

    题意: 就是让构造一个直径为d的树  每个结点的度数不能超过k 解析: 先构造出一条直径为d的树枝 然后去遍历这条树枝上的每个点  为每个点在不超过度数和直径的条件下添加子嗣即可 #include & ...

  7. 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration

    题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...

  8. 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= ...

  9. Codeforces Round #642 (Div. 3) D. Constructing the Array (优先队列)

    题意:有一个长度为\(n\)元素均为\(0\)的序列,进行\(n\)次操作构造出一个新序列\(a\):每次选择最长的连续为\(0\)的区间\([l,r]\),使得第\(i\)次操作时,\(a[\fra ...

随机推荐

  1. C++入门经典-例7.6-this指针,同一个类的不同对象数据

    1:对于类的非静态成员,每个对象都有自己的一份拷贝,即每个对象都有自己的数据成员,不过成员函数却是每个对象共享的.那么调用共享的成员函数如何找到自己的数据成员呢?答案是通过类中隐藏的this指针. 2 ...

  2. Nginx 配置443 HTTPS

    server { listen 443 ssl; server_name localhost; ssl on; ssl_certificate D://newlingshou//nginx-1.12. ...

  3. cha[] strrev(char[])

    反转字符串  保留在原函数中

  4. java编程出现的错误对应的解决方法

    error: could not open D:\java\jre1.8\lib\amd64\jvm.cfg 解决方法:把java的环境变量%JAVA_HOME%/bin上移到最上面 优化 查看网页源 ...

  5. mysql字符串函数:FIND_IN_SET()使用方法详解

    语法: FIND_IN_SET(str,strlist) 第一个参数str是要查找的字符串. 第二个参数strlist是要搜索的逗号分隔的字符串列表. 假如字符串str 在由N 子链组成的字符串列表s ...

  6. 转 Golang 入门 : 切片(slice)

    https://www.jianshu.com/p/354fce23b4f0 切片(slice)是 Golang 中一种比较特殊的数据结构,这种数据结构更便于使用和管理数据集合.切片是围绕动态数组的概 ...

  7. GitHub:Baidu

    ylbtech-GitHub:Baidu 1.返回顶部 · duedge-recipes DuEdge百度边缘网络计算样例代码 edgeedge-computingduedge    JavaScri ...

  8. [zookeeper]ZooInspector的使用

    一.背景   Zookeeper作为常用的集群协调者组件被广泛应用,尤其是在大数据生态圈中:   Zookeeper集群存储各个节点信息,包括:Hadoop.Hbase.Storm.Kafka等等: ...

  9. 从Docker在Linux和Windows下的区别简单理解Docker的层次结构

    上篇文章我们成功在Windows下安装了Docker,输出了一个简单的Hello World程序.本文中我们将利用Docker已有的云端镜像training/webapp来发布一个简单Python的W ...

  10. 阶段3 3.SpringMVC·_05.文件上传_3 文件上传之Springmvc方式上传原理分析

    需要配置文件解析器这个对象 id配置时候必须叫做mutipartResolver 最终