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\),那么\ ...
随机推荐
- 免费馅饼~-~ (hdu 1176
当我准备要写这个随笔的时候是需要勇气的. 掉馅饼嘛,肯定是坑. (hdu1176 话说,gameboy人品太好,放学回家路上有馅饼可捡.还就在0~10这11个位置里,当馅饼开始掉的时候,gameboy ...
- JavaWeb_(Struts2框架)Action中struts-default下result的各种转发类型
此系列博文基于同一个项目已上传至github 传送门 JavaWeb_(Struts2框架)Struts创建Action的三种方式 传送门 JavaWeb_(Struts2框架)struts.xml核 ...
- SVN_SVN的基本认识
SVN是什么? svn是Subversion的简称,是一个开源的代码版本控制系统,svn就是用于多人共同开发同一个项目,达到资源共用目的工具. 版本控制是什么? 版本控制(Revision contr ...
- MySQL_(Java)使用JDBC向数据库发起查询请求
MySQL_(Java)使用JDBC向数据库发起查询请求 传送门 MySQL_(Java)使用JDBC创建用户名和密码校验查询方法 传送门 MySQL_(Java)使用preparestatement ...
- [CSP-S模拟测试]:Drink(模拟)
题目传送门(内部题10) 输入格式 输入第一行三个数$N,M,Q$分别表示棋盘的行数.列数和操作个数.接下来$N$行每行$M$个数表示一开始棋盘上宝物的价值.接下来$Q$行每行$3$个数$x,y,c$ ...
- AIDL 的工作原理
当创建AIDL文件并Clean Project 代码后,会生成相应的Java文件: 先来一段伪代码:类整体结构 /* * This file is auto-generated. DO NOT MOD ...
- (三)C语言之变量
- pure-ftpd搭建简单的Ubuntu FTP服务器
Linux下的ftpd很多,Ubuntu下常用vsftpd, proftpd和pure-ftpd,当初使用的就是proftpd. 不过前两者有个致命的问题就是内码转换,它们默认使用UTF-8编码,而W ...
- 梯度下降(Gradient Descent)小结 -2017.7.20
在求解算法的模型函数时,常用到梯度下降(Gradient Descent)和最小二乘法,下面讨论梯度下降的线性模型(linear model). 1.问题引入 给定一组训练集合(training se ...
- list元素按照日期排序
private static void ListSort(List<AppClassInfoVo> list) { Collections.sort(list, new Comparato ...