n=C(2,n)+k(构造)( Print a 1337-string)Educational Codeforces Round 70 (Rated for Div. 2)
题目链接:https://codeforc.es/contest/1202/problem/D
题意:
给你一个数 n ( <=1e9 ),让你构造137713713.....(只含有1,3,7)的字符串使不同1337的子序列个数为n,而构造出来的字符串不能很长( <= 1e5)。
思路:
这类构造题肯定是要先固定一种方式,我尝试了以 C(2,a)+C(2,b)+C(2,c)+... = n 的形式,发现不行。后来还是看了别人的代码,
是以 C(2,m)+k 的形式组成 n,因为任意两个 n*(n-1) 和 (n-1)*(n-2) 之间相差的数量不会大于( 2*31622 ),因为根号下1e9是 ;
所以总长度不会大于 2*31622 (这是k的最大长度)+ (这是m的最大长度) 刚好是 <1e5。
所以答案就是 +(k个)+(m-2个)...
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>
#include <bitset>
//#include <map>
//#include<unordered_map> https://codeforc.es/contest/1202/problem/D
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
#define fo(a,b,c) for(register int a=b;a<=c;++a)
#define fr(a,b,c) for(register int a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
void swapp(int &a,int &b);
double fabss(double a);
int maxx(int a,int b);
int minn(int a,int b);
int Del_bit_1(int n);
int lowbit(int n);
int abss(int a);
//const long long INF=(1LL<<60);
const double E=2.718281828;
const double PI=acos(-1.0);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; int main()
{
int T;
sc("%d",&T);
while(T--)
{
int n;
sc("%d",&n);//C(2,n)+k;
int k=,m=;
for(int i=n;i>=;--i)
{
k=n-i;
int j=(int)sqrt(*i);
long long temp=j*(j+);
if(*i==temp)
{
m=j+;
break;
}
}
pr("");
fo(i,,k)
pr("");
fo(i,,m-)
pr("");
pr("");
cout<<endl;
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}
n=C(2,n)+k(构造)( Print a 1337-string)Educational Codeforces Round 70 (Rated for Div. 2)的更多相关文章
- Codeforces 1082 D. Maximum Diameter Graph-树的直径-最长链-构造题 (Educational Codeforces Round 55 (Rated for Div. 2))
D. Maximum Diameter Graph time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Educational Codeforces Round 62 (Rated for Div. 2)E(染色DP,构造,思维,组合数学)
#include<bits/stdc++.h>using namespace std;const long long mod=998244353;long long f[200007][2 ...
- Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)
D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Educational Codeforces Round 102 (Rated for Div. 2) B. String LCM (构造,思维)
题意:给你两个字符串\(a\)和\(b\),找出它们的\(lcm\),即构造一个新的字符串\(c\),使得\(c\)可以由\(x\)个\(a\)得到,并且可以由\(y\)个\(b\)得到,输出\(c\ ...
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- Educational Codeforces Round 73 (Rated for Div. 2) B. Knights(构造)
链接: https://codeforces.com/contest/1221/problem/B 题意: You are given a chess board with n rows and n ...
- Educational Codeforces Round 78 (Rated for Div. 2)E(构造,DFS)
DFS,把和当前结点相连的点全都括在当前结点左右区间里,它们的左端点依次++,然后对这些结点进行DFS,优先对左端点更大的进行DFS,这样它右端点会先括起来,和它同层的结点(后DFS的那些)的区间会把 ...
- Educational Codeforces Round 95 (Rated for Div. 2) B. Negative Prefixes (贪心,构造)
题意:给你一串长度为\(n\)的序列,有的位置被锁上了,你可以对没锁的位置上的元素任意排序,使得最后一个\(\le0\)的前缀和的位置最小,求重新排序后的序列. 题解:贪心,将所有能动的位置从大到小排 ...
- Educational Codeforces Round 94 (Rated for Div. 2) C. Binary String Reconstruction (构造)
题意:给你一个字符串\(s\),原字符串为\(w\),如果\(i>x\)且\(w_{i-x}=1\),那么\(s_{i}=1\),如果\(i+x\le n\)且\(w_{i+x}=1\),那么\ ...
随机推荐
- Cortex-M3 入门指南(三):时钟总线与复位时钟控制器
[reset clock control 复位和时钟控制器] 时钟信号对于处理器非常重要,比如我们熟悉的 CPU 就是由时钟信号驱动的,而主频就是内核的的时钟信号频率.Cortex-M3 有着复杂的 ...
- Codeforces 785 D.Anton and School - 2(组合数处理)
Codeforces 785 D.Anton and School - 2 题目大意:从一串由"(",")"组成的字符串中,找出有多少个子序列满足:序列长度为偶 ...
- 在Latex中,拉普拉斯算子的小写符号l怎么表示
如下图所示的小写字母l,在Latex中不知道该如何表示,试过用\mathcal但是发现不行,因为\mathcal只支持大写字母. 正确方法: \ell
- 22.Python赋值运算符(入门必读)
赋值运算符主要用来为变量(或常量)赋值,在使用时,既可以直接用基本赋值运算符“=”将右侧的值赋给左侧的变量,右侧也可以在进行某些运算后再赋值给左侧的变量. = 基本赋值运算符 Python 使用“=” ...
- struct streaming中的监听器StreamingQueryListener
在struct streaming提供了一个类,用来监听流的启动.停止.状态更新 StreamingQueryListener 实例化:StreamingQueryListener 后需要实现3个函数 ...
- 已知源目录路径sourceFilePath,此目录下还有多级子目录和多个文本文件(*.txt)。尝试编写一个方法,将此目录下所有的文件拷贝至另一个目录targetFilePath,并其中的文本文件修改成SQL文件(*.SQL)。
public void copyFile(String oldPath, String newPath) throws IOException { (new File(newPath)).mkdirs ...
- python3笔记十七:python文件读写
一:学习内容 读文件 写文件 编码与解码 二:读文件--步骤分解 1.过程 第一步:打开文件第二步:读文件内容第三步:关闭文件 2.第一步:打开文件 open(path,flag[,encoding] ...
- 如何安装Vscode软件及设置成中文界面?
最新小编开始研究前端,想写点东东玩,要想开始首先就要安装工具,写前端有好几个工具,安装推荐开源的vscode,第一次安装是英文版的,如何修改成中文版,也是很简单的,跟随小编一起来安装设置工具吧. 方法 ...
- Php+Redis函数使用总结
因项目需求,冷落了redis,今天再重新熟悉一下: <?php //连接 $redis = New Redis(); $redis->connect('127.0.0.1','6379', ...
- sptringboot2.0实现aop
题记:在项目需要对请求日志情形管理. 声明:参考博客https://blog.csdn.net/bombsklk/article/details/79143145 1.在pom.xml中加入依赖 &l ...