题目链接: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. jenkin 构建失败 才发邮件通知

    使用场景:自动化测试,一般需要配置定时执行(每天执行一次,没周执行一次),如果有失败,则发邮件给相关人员关注.此时需要使用jenkins的邮件发送配置.修改job的configure配置步骤如下: 1 ...

  2. Centos 7.6安装mysql服务端5.7

    环境:centos 7.6,mysql server 5.7.26 新建文件夹/opt/mysql,并cd进去 运行wget http://dev.mysql.com/get/mysql-5.7.26 ...

  3. JVM(11)之 G1收集器

    开发十年,就只剩下这套架构体系了! >>>   在前两篇博文中讲解了新生代和年老代的收集器,在本篇博文中介绍一个收集范围涵盖整个堆的收集器--G1收集器.  先讲讲G1收集器的特点, ...

  4. shell 脚本规范

    shell 脚本规范 一.背景 1.使用哪一种shell? 必须使用bash shell 2.什么时候使用shell? 数量相对较少的操作 脚本文件少于100行 3.脚本文件扩展名是什么? shell ...

  5. vue.js(09)--v-for中的key

    v-for中key的使用注意事项 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  6. ahocorasick使用

    一.作用 字符串匹配,比如现在有个大的列表,客户输入一句话,如何根据客户输入的一句话,从大列表中匹配出字符串交集 具体请详细查阅 二.示例 比如我们有一个wordlist列表,长度很长,包含43430 ...

  7. Linux就该这么学10学习笔记

    参考链接:https://www.linuxprobe.com/chapter-10.html 网站服务程序 第1步:把光盘设备中的系统镜像挂载到/media/cdrom目录. [root@linux ...

  8. QT + openssl + VS2015静态编译

    从http://slproweb.com/products/Win32OpenSSL.html下载已经编译好的openssl,一路next 我将OpenSSL-Win32\lib\VC目录下的libe ...

  9. Hibernate 一对多配置 级联操作(级联失败问题分析解决)

    一方: package com.xdfstar.domain; import java.io.Serializable;import java.util.Date;import java.util.H ...

  10. 51nod 1253:Kundu and Tree(组合数学)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1253 所有的三元组的可能情况数有ans0=C(n,3).然后 ...