Small topic Pan-do

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.