n=C(2,n)+k(构造)( Print a 1337-string)Educational Codeforces Round 70 (Rated for Div. 2)

Topic links: https://codeforc.es/contest/1202/problem/D

Meaning of the questions:

To give you a number n (<= 1e9), configured so that you string ..... 137 713 713 (only containing 1,3,7) so that the number of different sub-sequences 1337 is n- , constructed out of the string can not be long (<= 1E5) .

Ideas:

This type of configuration problem must be fixed first one way, I tried to C (2, a) + C (2, b) + C (, c 2) + ... = n form, found not. Later still I read other people's code,

Is C (2, m) + k in the form of a composition n, since any two n * (n-1) and (n-1) * (n -2) number is not greater than the difference between the ( 2 * 31622 ), because the root 1e9 is 31622 ;

So the total length is not greater than 2 * 31622 (which is the maximum length k) + 31 622 (which is the maximum length m) is exactly 94868 <1E5.

So the answer is  133 + 7 (K th) + 3333 (two m-2) ... 7

  1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
  2 #include <cstdio>//sprintf islower isupper
  3 #include <cstdlib>//malloc  exit strcat itoa system("cls")
  4 #include <iostream>//pair
  5 #include <fstream>
  6 #include <bitset>
  7 //#include <map>
  8 //#include<unordered_map>  https://codeforc.es/contest/1202/problem/D
  9 #include <vector>
 10 #include <stack>
 11 #include <set>
 12 #include <string.h>//strstr substr
 13 #include <string>
 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
 15 #include <cmath>
 16 #include <deque>
 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
 18 #include <vector>//emplace_back
 19 //#include <math.h>
 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
 23 #define fo(a,b,c) for(register int a=b;a<=c;++a)
 24 #define fr(a,b,c) for(register int a=b;a>=c;--a)
 25 #define mem(a,b) memset(a,b,sizeof(a))
 26 #define pr printf
 27 #define sc scanf
 28 #define ls rt<<1
 29 #define rs rt<<1|1
 30 void swapp(int &a,int &b);
 31 double fabss(double a);
 32 int maxx(int a,int b);
 33 int minn(int a,int b);
 34 int Del_bit_1(int n);
 35 int lowbit(int n);
 36 int abss(int a);
 37 //const long long INF=(1LL<<60);
 38 const double E=2.718281828;
 39 const double PI=acos(-1.0);
 40 const int inf=(1<<29);
 41 const double ESP=1e-9;
 42 const int mod=(int)1e9+7;
 43 const int N=(int)1e6+10;
 44 
 45 int main()
 46 {
 47     int T;
 48     sc("%d",&T);
 49     while(T--)
 50     {
 51         int n;
 52         sc("%d",&n);//C(2,n)+k;
 53         int k=0,m=0;
 54         for(int i=n;i>=1;--i)
 55         {
 56             k=n-i;
 57             int j=(int)sqrt(2*i);
 58             long long temp=j*(j+1);
 59             if(2*i==temp)
 60             {
 61                 m=j+1;
 62                 break;
 63             }
 64         }
 65         pr("133");
 66         fo(i,1,k)
 67             pr("7");
 68         fo(i,1,m-2)
 69             pr("3");
 70         pr("7");
 71         cout<<endl;
 72     }
 73     return 0;
 74 }
 75 
 76 /**************************************************************************************/
 77 
 78 int maxx(int a,int b)
 79 {
 80     return a>b?a:b;
 81 }
 82 
 83 void swapp(int &a,int &b)
 84 {
 85     a^=b^=a^=b;
 86 }
 87 
 88 int lowbit(int n)
 89 {
 90     return n&(-n);
 91 }
 92 
 93 int Del_bit_1(int n)
 94 {
 95     return n&(n-1);
 96 }
 97 
 98 int abss(int a)
 99 {
100     return a>0?a:-a;
101 }
102 
103 double fabss(double a)
104 {
105     return a>0?a:-a;
106 }
107 
108 int minn(int a,int b)
109 {
110     return a<b?a:b;
111 }

 

Guess you like

Origin www.cnblogs.com/--HPY-7m/p/11333199.html