Topic 1 Codeforces 605 A
Topic: Given a sequence of length n, each time you can put a number to the beginning or the last, the minimum number of rows in ascending order.
The longest ascending subsequence of the original sequence position is obtained, minus the largest by N. We just have to make sure the relative size is the same.
Code:
1#include <cstdio>2#include <iostream>3#include <algorithm>4#include <cstdlib>5#include <cstring>6 7 using namespacestd;8 9 Const intN =100000+5;Ten One intN, A[n], dp[n], pos[n]; A - intMain () { -scanf"%d", &n); the for(inti =1; I <= N; + + i) scanf ("%d", &a[i]); - for(inti =1; I <= N; + + i) pos[a[i]] =i; -dp[1] =1; - for(inti =2; I <= N; ++i) + if(Pos[i] > Pos[i-1]) Dp[i] = dp[i-1] +1; - ElseDp[i] =1; +printf"%d\n", N-*max_element (DP +1, DP + n +1)); A return 0; at}
605A
Topic 2 51nod finding factorial length
Title: Title.
Code:
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <algorithm>5#include <cstring>6#include <iomanip>7#include <queue>8#include <stack>9#include <ctime>Ten #definell Long Long One A using namespacestd; - - Const DoublePi=acos (-1.0); the Const DoubleE=exp (1); - - intMain () { - ll N; +scanf"%lld",&n); - if(n==1) {printf ("1\n");return 0;} +ll ans=0.5*LOG10 (2.0*pi*n) + N*LOG10 (n1.0/e) +1; Aprintf"%lld\n", ans); at return 0; -}
! Lens
Small topic Pan-do