题目链接:https://codeforces.com/problemset/problem/1202/D


题意:

构造一串只由 ‘1’,‘3’,‘7’ 组成的字符串,使其 ‘1337’ 子序列数量为n

思路:

构造 ‘13377733337’ 类型的字符串,使 C(m,2)+k=n

k为中间 ‘7’ 的数量,C(m,2)为中间 ‘3’ 的数量

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(int i=m;i<n;i++)
const int N = 2e5+;
ll a[],b[]; int main(){
ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int t,n;
cin>>t;
while(t--){
cin>>n;
int num=sqrt(n*),x,y;
rep(i,num,*n+){
if(i*(i-)<=*n)
x=i,y=n-i*(i-)/;
else
break;
}
cout<<"";
rep(i,,y)
cout<<"";
rep(i,,x-)
cout<<"";
cout<<""<<endl;
}
return ;
}

[题解]Print a 1337-string...-数学(codeforces 1202D)的更多相关文章

  1. iOS开发调试篇—Print Description of "string"

    Print Description of "string":把 string 的信息输出到控制台.Copy:复制 string 的信息,包含变量名,类名和值.View Value ...

  2. 【CodeForces】708 B. Recover the String 数学构造

    [题目]B. Recover the String [题意]找到一个串s,满足其中子序列{0,0}{0,1}{1,0}{1,1}的数量分别满足给定的数a1~a4,或判断不存在.数字<=10^9, ...

  3. Codeforces 1204D Kirk and a Binary String - 数学

    题目传送门 传送门 群除我均会猜结论/找规律,sad.... 以下内容只保证代码能过system test,证明应该都是在纯口胡 约定下文中的$LIS$表示最长不下降子序列. 定义$zero(s)$表 ...

  4. Codeforces - 1202D - Print a 1337-string... - 构造

    https://codeforces.com/contest/1202/problem/D 当时想的构造是中间两个3,然后前后的1和7组合出n,问题就是n假如是有一个比较大的质数因子或者它本身就是质数 ...

  5. 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet

    题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...

  6. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  7. 数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun

    题目传送门 /* 数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了 另外不足一个区间的直接计算个数就可以了 */ #include <cstdio> #i ...

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

  9. 数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun

    题目传送门 /* 水题,就是用三点共线的式子来判断射击次数 */ #include <cstdio> #include <cmath> #include <string& ...

随机推荐

  1. 洛谷 P3368 【模板】树状数组 2(区间加,单点查询)

    题目链接 https://www.luogu.org/problemnew/show/P3368 树状数组 最基础的用法:https://www.cnblogs.com/yinyuqin/p/1096 ...

  2. AC自动机题单

    AC自动机题目 真的超级感谢xzy 真的帮到我很多 题单 [X] [luogu3808][模板]AC自动机(简单版) https://www.luogu.org/problemnew/show/P38 ...

  3. spark连接hive找不到table

    Caused by: org.apache.spark.sql.catalyst.analysis.NoSuchTableException: Table or view 'xxxx' not fou ...

  4. Windows下anaconda安装opencv

    win+R打开cmd界面,输入conda create -n opencv python=3.6,创建名为opencv的虚拟空间,然后一路y,直到安装完成. activate opencv 然后输入  ...

  5. springcloud费话之配置中心客户端(SVN)

    目录: springcloud费话之Eureka基础 springcloud费话之Eureka集群 springcloud费话之Eureka服务访问(restTemplate) springcloud ...

  6. Java JNA (一)—— 调用dll

    Java调用C++动态链接库的方式很多,有jnative,jna等.这里介绍如何通过jna的方式调用动态链接库. 调用代码很简单,就是需要注意几个问题. 补充:如dll内部访问配置文件,需将配置文件放 ...

  7. Python人工智能识别文字内容(OCR)

    环境准备 安装pytesseract和PIL 安装这两个包可以借助pip命令行安装 pip install PIL pip install pytesseract 安装识别引擎tesseract-oc ...

  8. Spring 事物机制(总结)

    Spring两种事物处理机制,一是声明式事物,二是编程式事物 声明式事物 1)Spring的声明式事务管理在底层是建立在AOP的基础之上的.其本质是对方法前后进行拦截,然后在目标方法开始之前创建或者加 ...

  9. Mybatis 单表 常用增删改查

    1.编写sql表,插入原始数据 -- 删除表 DROP TABLE testA; -- 创建表 CREATE TABLE testA( id INT AUTO_INCREMENT PRIMARY KE ...

  10. git提交代码冲突解决

    1.git stash save "说明信息" 2.git stash lish 3.git pull 4.git stash pop stash@{编号}